Err

Enum Err 

Source
pub enum Err {
    Len,
    Prefix,
    DuplicateName,
    UnknownName,
    UnknownMetric,
    MissingMandatoryMetrics,
    UnknownSeverity,
    InvalidMacroVector,
    UnknownVersion,
    UnknownNomenclature,
}
Expand description

Parse or conversion error.

§Examples

Try to parse an invalid vector string:

// try to parse invalid vector string, then the check result
assert_eq!("asdf".parse::<Vector>(), Err(Err::Len));

Convert an Err to a printable string:

assert_eq!(Err::DuplicateName.to_string(), "Vector string contains a duplicate metric name");

Variants§

§

Len

String is too short to contain a CVSS vector string.

§Example

// parse invalid string as vector, then check result
assert_eq!("asdf".parse::<Vector>(), Err(Err::Len));
§

Prefix

String does not begin with a CVSS: prefix.

§Example

// parse invalid string as vector, then check result
assert_eq!("CVSS:foo/".parse::<Vector>(), Err(Err::Prefix));
§

DuplicateName

Vector string contains a duplicate metric name.

§Example

// parse invalid string as vector, then check result
assert_eq!("CVSS:4.0/AV:N/AV:N".parse::<Vector>(), Err(Err::DuplicateName));
§

UnknownName

Unknown metric name.

§Example

// parse unknown metric name, check result
assert_eq!("asdf".parse::<Name>(), Err(Err::UnknownName));
§

UnknownMetric

Vector string contains an unknown metric.

§Example

// parse vector string with unknown metric value, then check result
assert_eq!("CVSS:4.0/AV:Z".parse::<Vector>(), Err(Err::UnknownMetric));

// parse vector string with unknown metric name, then check result
assert_eq!("CVSS:4.0/ZZ:Z".parse::<Vector>(), Err(Err::UnknownMetric));
§

MissingMandatoryMetrics

Vector string is missing mandatory metrics.

§Example

// vector string missing mandatory metric
let s = "CVSS:4.0/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H";

// parse string, check result
assert_eq!(s.parse::<Vector>(), Err(Err::MissingMandatoryMetrics));
§

UnknownSeverity

Unknown severity name.

§Example

// vector string missing mandatory metric
let s = "asdf";

// parse string, check result
assert_eq!(s.parse::<Severity>(), Err(Err::UnknownSeverity));
§

InvalidMacroVector

Invalid v4::MacroVector digit.

A digit of a v4::MacroVector is out of range.

§Example

// parse unknown CVSS version, check result
assert_eq!(MacroVector::try_from(123456), Err(Err::InvalidMacroVector));
§

UnknownVersion

Unknown CVSS version.

§Example

// parse unknown CVSS version, check result
assert_eq!("asdf".parse::<Version>(), Err(Err::UnknownVersion));
§

UnknownNomenclature

Unknown v4::Nomenclature.

§Example

// parse unknown CVSS v4 nomenclature, check result
assert_eq!("asdf".parse::<Nomenclature>(), Err(Err::UnknownNomenclature));

Trait Implementations§

Source§

impl Clone for Err

Source§

fn clone(&self) -> Err

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Err

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Err

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Err

Source§

fn eq(&self, other: &Err) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Err

Source§

impl Eq for Err

Source§

impl StructuralPartialEq for Err

Auto Trait Implementations§

§

impl Freeze for Err

§

impl RefUnwindSafe for Err

§

impl Send for Err

§

impl Sync for Err

§

impl Unpin for Err

§

impl UnwindSafe for Err

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.