5 releases (3 breaking)

0.4.1 Aug 30, 2024
0.4.0 May 27, 2024
0.3.0 Jul 2, 2021
0.2.0 Jun 14, 2018
0.1.0 Apr 13, 2018

#213 in Parser implementations

Download history 4811/week @ 2024-07-18 3576/week @ 2024-07-25 3324/week @ 2024-08-01 3462/week @ 2024-08-08 6058/week @ 2024-08-15 3536/week @ 2024-08-22 2931/week @ 2024-08-29 3781/week @ 2024-09-05 2876/week @ 2024-09-12 2867/week @ 2024-09-19 3049/week @ 2024-09-26 3017/week @ 2024-10-03 2667/week @ 2024-10-10 4634/week @ 2024-10-17 4010/week @ 2024-10-24 4156/week @ 2024-10-31

16,084 downloads per month
Used in 12 crates (6 directly)

MIT license

47KB
1K SLoC

packageurl-rs Star me

Read and generate Package URLs in Rust.

Actions Codecov Source Crate Documentation 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.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.

📝 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

~0.3–0.9MB
~19K SLoC