pub struct Uri<'a> { /* private fields */ }
Expand description
A CPE 2.2 URI
Note: field access is limited to ensure values only contain
semantically valid components. Fields can be accessed through the
“getter” methods, or through the Cpe methods,
although the former is preferred with a Cpe
as opposed to an OwnedCpe
.
Display is implemented to show the decoded contents by default, or to re-encode
the components when #
is used to specify an alternate.
use cpe::uri::Uri;
let uri = Uri::builder()
.part("a")
.vendor("foo%21")
.validate()
.unwrap();
assert_eq!(format!("{}", uri), "cpe:/a:foo!:*:*:*:*:*".to_owned());
assert_eq!(format!("{:#}", uri), "cpe:/a:foo%21:*:*:*:*:*".to_owned());
Additionally, the 0
for zero-padding integers can be used to omit default “*” fields.
use cpe::uri::Uri;
let uri = Uri::builder()
.part("a")
.vendor("foo%21")
.validate()
.unwrap();
assert_eq!(format!("{:0}", uri), "cpe:/a:foo!".to_owned());
assert_eq!(format!("{:#0}", uri), "cpe:/a:foo%21".to_owned());
Implementations§
source§impl<'a> Uri<'a>
impl<'a> Uri<'a>
sourcepub fn builder() -> CpeBuilder<'a, Uri<'a>>
pub fn builder() -> CpeBuilder<'a, Uri<'a>>
Create a CpeBuilder
struct to construct a new Wfn.
use cpe::uri::Uri;
let cpe: Uri = Uri::builder()
.part("a")
.vendor("rust")
.product("cargo")
.validate()
.unwrap();
println!("{:?}", cpe);
sourcepub fn set_part(&mut self, part: &'a str) -> Result<()>
pub fn set_part(&mut self, part: &'a str) -> Result<()>
Set the CPE type part, a
, o
, h
, or *
.
The provided string slice will be parsed to its semantic meaning.
sourcepub fn set_vendor(&mut self, vendor: &'a str) -> Result<()>
pub fn set_vendor(&mut self, vendor: &'a str) -> Result<()>
Set the CPE vendor.
The provided string slice will be parsed to its semantic meaning.
sourcepub fn set_product(&mut self, product: &'a str) -> Result<()>
pub fn set_product(&mut self, product: &'a str) -> Result<()>
Set the CPE product.
The provided string slice will be parsed to its semantic meaning.
sourcepub fn set_version(&mut self, version: &'a str) -> Result<()>
pub fn set_version(&mut self, version: &'a str) -> Result<()>
Set the CPE product.
The provided string will be parsed to its semantic meaning.
sourcepub fn set_update(&mut self, update: &'a str) -> Result<()>
pub fn set_update(&mut self, update: &'a str) -> Result<()>
Set the CPE update.
The provided string will be parsed to its semantic meaning.
sourcepub fn set_edition(&mut self, edition: &'a str) -> Result<()>
pub fn set_edition(&mut self, edition: &'a str) -> Result<()>
Set the CPE edition.
The provided string will be parsed to its semantic meaning.
Note that this funciton will unpack a packed ~
delimited edition component if applicable.
sourcepub fn set_language(&mut self, language: &'a str) -> Result<()>
pub fn set_language(&mut self, language: &'a str) -> Result<()>
Set the CPE language.
The provided string will be parsed to its semantic meaning.
language
must be a valid RFC-5646 language tag.