Crate packageurl[−][src]
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::str::FromStr; use packageurl::PackageUrl; let purl = PackageUrl::from_str("pkg:npm/%40angular/animation@12.3.1").unwrap(); assert!(purl.name == "animation"); assert!(purl.namespace.unwrap() == "@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!(err.description() == "missing scheme");
The parsed PackageUrl
will have a 'static
lifetime, so that the parsed string can be
safely discarded.
Modules
errors |
Error type and other helpers using the |
Structs
PackageUrl |
A Package URL. |