[][src]Struct cpe::wfn::Wfn

pub struct Wfn<'a> { /* fields omitted */ }

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

impl<'a> Wfn<'a>[src]

pub fn new() -> Self[src]

Create a default Wfn with all fields set to ANY.

pub fn builder() -> CpeBuilder<'a, Wfn<'a>>[src]

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);

pub fn set_part(&mut self, part: &'a str) -> Result<()>[src]

Set the CPE type part, a, o, h, or *.

The provided string slice will be parsed to its semantic meaning.

pub fn set_vendor(&mut self, vendor: &'a str) -> Result<()>[src]

Set the CPE vendor.

The provided string slice will be parsed to its semantic meaning.

pub fn set_product(&mut self, product: &'a str) -> Result<()>[src]

Set the CPE product.

The provided string slice will be parsed to its semantic meaning.

pub fn set_version(&mut self, version: &'a str) -> Result<()>[src]

Set the CPE product.

The provided string will be parsed to its semantic meaning.

pub fn set_update(&mut self, update: &'a str) -> Result<()>[src]

Set the CPE update.

The provided string will be parsed to its semantic meaning.

pub fn set_edition(&mut self, edition: &'a str) -> Result<()>[src]

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.

pub fn set_language(&mut self, language: &'a str) -> Result<()>[src]

Set the CPE language.

The provided string will be parsed to its semantic meaning. language must be a valid RFC-5646 language tag.

pub fn set_sw_edition(&mut self, sw_edition: &'a str) -> Result<()>[src]

Set the CPE software edition.

The provided string will be parsed to its semantic meaning.

pub fn set_target_sw(&mut self, target_sw: &'a str) -> Result<()>[src]

Set the CPE target software.

The provided string will be parsed to its semantic meaning.

pub fn set_target_hw(&mut self, target_hw: &'a str) -> Result<()>[src]

Set the CPE target hardware.

The provided string will be parsed to its semantic meaning.

pub fn set_other(&mut self, other: &'a str) -> Result<()>[src]

Set the CPE "other" value.

The provided string will be parsed to its semantic meaning.

pub fn to_owned(&self) -> OwnedWfn[src]

Create an Owned copy of this CPE WFN.

pub fn as_uri(&self) -> Uri<'a>[src]

Create a Uri, perserving lifetimes of the original input. Note that strings may be cloned if the input was decoded.

pub fn parse(value: &'a str) -> Result<Self>[src]

Parse a CPE URI string.

This function will decode percent encodings and special characters to their semantic meaning.

Trait Implementations

impl<'_> Cpe for Wfn<'_>[src]

impl<'a> Debug for Wfn<'a>[src]

impl<'a> Default for Wfn<'a>[src]

impl<'_> Display for Wfn<'_>[src]

impl<'a, '_> From<&'_ Uri<'a>> for Wfn<'a>[src]

impl<'_, '_> From<&'_ Wfn<'_>> for OwnedUri[src]

impl<'_, '_> From<&'_ Wfn<'_>> for OwnedWfn[src]

impl<'a, '_> From<&'_ Wfn<'a>> for Uri<'a>[src]

impl<'a> From<Uri<'a>> for Wfn<'a>[src]

impl<'_> From<Wfn<'_>> for OwnedUri[src]

impl<'_> From<Wfn<'_>> for OwnedWfn[src]

impl<'a> From<Wfn<'a>> for Uri<'a>[src]

impl<'a> PartialEq<Wfn<'a>> for Wfn<'a>[src]

impl<'a> StructuralPartialEq for Wfn<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for Wfn<'a>

impl<'a> Send for Wfn<'a>

impl<'a> Sync for Wfn<'a>

impl<'a> Unpin for Wfn<'a>

impl<'a> UnwindSafe for Wfn<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.