Crate packageurl[][src]

Expand description

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

Parsing

Parse a package url after bringing the FromStr trait in scope:

use std::borrow::Cow;
use std::str::FromStr;
use packageurl::PackageUrl;

let purl = PackageUrl::from_str("pkg:npm/%40angular/animation@12.3.1").unwrap();
assert_eq!(purl.name(), "animation");
assert_eq!(purl.namespace(), Some("@angular"));

Parsing a purl may fail, in which case an error kind from the [errors] module is returned:

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

let err = PackageUrl::from_str("package@0.1.0").unwrap_err();
assert_eq!(err, packageurl::Error::MissingScheme);

The parsed PackageUrl will have a 'static lifetime, so that the parsed string can be safely discarded.

Structs

A Package URL.

Enums

Type Definitions