pub struct Wfn<'a> { /* private fields */ }
Expand description
A CPE 2.3 Well-Formed Name
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::wfn::Wfn;
let wfn = Wfn::builder()
.part("a")
.vendor("foo\\!")
.validate()
.unwrap();
assert_eq!(format!("{}", wfn), "wfn:[part=a,vendor=foo!,product=ANY,version=ANY,update=ANY,edition=ANY,language=ANY,sw_edition=ANY,target_sw=ANY,target_hw=ANY,other=ANY]".to_owned());
assert_eq!(format!("{:#}", wfn), "wfn:[part=a,vendor=foo\\!,product=ANY,version=ANY,update=ANY,edition=ANY,language=ANY,sw_edition=ANY,target_sw=ANY,target_hw=ANY,other=ANY]".to_owned());
Additionally, the 0
for zero-padding integers can be used to omit default “ANY” fields.
use cpe::wfn::Wfn;
let wfn = Wfn::builder()
.part("a")
.vendor("foo\\!")
.validate()
.unwrap();
assert_eq!(format!("{:0}", wfn), "wfn:[part=a,vendor=foo!]".to_owned());
assert_eq!(format!("{:#0}", wfn), "wfn:[part=a,vendor=foo\\!]".to_owned());
Implementations§
source§impl<'a> Wfn<'a>
impl<'a> Wfn<'a>
sourcepub fn builder() -> CpeBuilder<'a, Wfn<'a>>
pub fn builder() -> CpeBuilder<'a, Wfn<'a>>
Create a CpeBuilder
struct to construct a new Wfn.
use cpe::wfn::Wfn;
let cpe: Wfn = Wfn::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 not unpack a packed ~
delimited edition component.
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.
sourcepub fn set_sw_edition(&mut self, sw_edition: &'a str) -> Result<()>
pub fn set_sw_edition(&mut self, sw_edition: &'a str) -> Result<()>
Set the CPE software edition.
The provided string will be parsed to its semantic meaning.
sourcepub fn set_target_sw(&mut self, target_sw: &'a str) -> Result<()>
pub fn set_target_sw(&mut self, target_sw: &'a str) -> Result<()>
Set the CPE target software.
The provided string will be parsed to its semantic meaning.
sourcepub fn set_target_hw(&mut self, target_hw: &'a str) -> Result<()>
pub fn set_target_hw(&mut self, target_hw: &'a str) -> Result<()>
Set the CPE target hardware.
The provided string will be parsed to its semantic meaning.
sourcepub fn set_other(&mut self, other: &'a str) -> Result<()>
pub fn set_other(&mut self, other: &'a str) -> Result<()>
Set the CPE “other” value.
The provided string will be parsed to its semantic meaning.