packageurl 0.1.0

Rust implementation of the package url specification
Documentation

packageurl

Read and generate Package URLs in Rust.

TravisCI Codecov Source Crate Documentation CargoMake Changelog SayThanks

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.1.0"

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

extern crate packageurl
use std::str::FromStr;
use packageurl::PackageUrl;

let purl = PackageUrl::from_str("cargo:packageurl@0.1.0")

Generate a canonical PURL using the ToString trait:

extern crate packageurl;
use std::string::ToString;
use package::PackageUrl;

let canonical = PackageUrl::new("cargo", "packageurl")
    .with_version("0.1.0")
    .to_string();

See more in the online documentation.

Note

The specification is not completely enforced right now: in particular, it will allow building Package URLs with invalid namespaces and the like. More validations and errors are to be added in the future.