pub struct Purpose {
role: Role,
mode: Mode,
}Expand description
Fields§
§role: Role§mode: ModeImplementations§
Source§impl Purpose
impl Purpose
Sourcepub fn parser(input: &mut &str) -> Result<Purpose, ErrMode<ContextError>>
pub fn parser(input: &mut &str) -> Result<Purpose, ErrMode<ContextError>>
Recognizes a Purpose in a string slice.
§Errors
§Examples
use voa_core::identifiers::{Mode, Purpose, Role};
use winnow::Parser;
assert_eq!(
Purpose::parser.parse("trust-anchor-test")?,
Purpose::new(Role::Custom("test".parse()?), Mode::TrustAnchor),
);
assert_eq!(
Purpose::parser.parse("test")?,
Purpose::new(Role::Custom("test".parse()?), Mode::ArtifactVerifier),
);Sourcepub fn purpose_to_string(&self) -> String
pub fn purpose_to_string(&self) -> String
A String representation of this Purpose specifier.
This function produces the exact representation specified in https://uapi-group.org/specifications/specs/file_hierarchy_for_the_verification_of_os_artifacts/#purpose
Sourcepub fn is_trust_anchor(&self) -> bool
pub fn is_trust_anchor(&self) -> bool
Checks whether self uses Mode::TrustAnchor.
Returns true if self uses Mode::TrustAnchor, false otherwise.
Sourcepub fn to_trust_anchor(self) -> Purpose
pub fn to_trust_anchor(self) -> Purpose
Consumes self and returns a Purpose which uses Mode::TrustAnchor.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Purpose
impl<'de> Deserialize<'de> for Purpose
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Purpose, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Purpose, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<Purpose> for ConfigPurpose
impl From<Purpose> for ConfigPurpose
Source§impl Ord for Purpose
impl Ord for Purpose
Source§impl PartialOrd for Purpose
impl PartialOrd for Purpose
Source§impl Serialize for Purpose
impl Serialize for Purpose
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Eq for Purpose
impl StructuralPartialEq for Purpose
Auto Trait Implementations§
impl Freeze for Purpose
impl RefUnwindSafe for Purpose
impl Send for Purpose
impl Sync for Purpose
impl Unpin for Purpose
impl UnwindSafe for Purpose
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
Fallible version of [
ToCompactString::to_compact_string()] Read more§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a [
CompactString]. Read more