Crates.io | packageurl |
lib.rs | packageurl |
version | 0.4.1 |
source | src |
created_at | 2018-04-13 20:27:30.304765 |
updated_at | 2024-08-30 07:14:47.096018 |
description | Rust implementation of the package url specification |
homepage | |
repository | https://github.com/althonos/packageurl-rs |
max_upload_size | |
id | 60489 |
size | 78,364 |
packageurl-rs
Read and generate Package URLs in Rust.
This crate is an implementation of the Package URL specification for the Rust programming language.
Add this crate to the Cargo.toml
:
[dependencies]
packageurl = "0.4.1"
Parse a string containing a raw PURL using the
FromStr
trait:
extern crate packageurl;
use std::str::FromStr;
use packageurl::PackageUrl;
fn example() {
let purl = PackageUrl::from_str("pkg:cargo/packageurl@0.3.0");
}
Creating a PURL from Rust and then generating a string representation using:
the ToString
trait:
extern crate packageurl;
use std::string::ToString;
fn example() {
let canonical = package::PackageUrl::new("cargo", "packageurl")
.expect("only fails if type is invalid")
.with_version("0.3.0")
.to_string();
}
serde
serialization and deserialization is also supported, provided the
serde
feature is enabled:
[dependencies]
packageurl = { version = "0.4.1", features = ["serde"] }
See more in the online documentation.
memchr
: use the memchr
crate to locate
separator when parsing.serde
: enable serialization and deserialization support with the
serde
crate.This project adheres to Semantic Versioning and provides a changelog as part of the GitHub releases.
Found a bug? Have an enhancement request? Head over to the GitHub issue tracker of the project if you need to report or ask something. If you are filling in on a bug, please include as much information as you can about the issue, and try to recreate the same bug in a simple, easily reproducible situation.
This library is provided under the open-source MIT license.