9 unstable releases

new 0.5.0-rc.9 May 6, 2025
0.4.2 Apr 7, 2025
0.4.1 Aug 30, 2024
0.4.0 May 27, 2024
0.1.0 Apr 13, 2018

#148 in Parser implementations

Download history 2513/week @ 2025-01-16 2860/week @ 2025-01-23 3688/week @ 2025-01-30 2427/week @ 2025-02-06 2694/week @ 2025-02-13 3377/week @ 2025-02-20 2570/week @ 2025-02-27 2593/week @ 2025-03-06 1833/week @ 2025-03-13 2154/week @ 2025-03-20 2313/week @ 2025-03-27 3241/week @ 2025-04-03 2177/week @ 2025-04-10 1398/week @ 2025-04-17 1909/week @ 2025-04-24 2318/week @ 2025-05-01

8,661 downloads per month
Used in 12 crates (7 directly)

MIT license

44KB
750 lines

packageurl-rs Star me

Read and generate Package URLs in Rust.

CI crates.io docs.rs GitHub issues

About

This crate is an implementation of the Package URL specification for the Rust programming language.

🔌 Usage

Add this crate to the Cargo.toml:

[dependencies]
packageurl = "0.5.0"

Parse a string containing a raw PURL using the FromStr trait:

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:

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.5.0", features = ["serde"] }

See more in the online documentation.

📝 Features

  • memchr: use the memchr crate to locate separator when parsing.
  • serde: enable serialization and deserialization support with the serde crate.

📋 Changelog

This project adheres to Semantic Versioning and provides a changelog as part of the GitHub releases.

💭 Feedback

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.

⚖️ License

This library is provided under the open-source MIT license.

Dependencies

~230–790KB
~18K SLoC