1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//! `packageurl` is an implementation of the [Package URL] specification for the [Rust] programming language.
//!
//! [Rust]: http://rust-lang.org/
//! [Package URL]: https://github.com/package-url/purl-spec
//!
//!
//! # Parsing
//!
//! Parse a package url after bringing the [`FromStr`] trait in scope:
//! ```rust
//! 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:
//! ```rust
//! 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.
//!
//! [`FromStr`]: https://doc.rust-lang.org/std/str/trait.FromStr.html
//! [`PackageUrl`]: example_generated/struct.PackageUrl.html
//! [`'static`]: https://doc.rust-lang.org/reference/items/static-items.html#static-lifetime-elision
pub use Error;
pub use Result;
pub use PackageUrl;