pub struct CustomRole(IdentifierString);
Expand description
A custom value for a Role
Tuple Fields§
§0: IdentifierString
Implementations§
Source§impl CustomRole
impl CustomRole
Sourcepub fn new(role: IdentifierString) -> Result<Self, Error>
pub fn new(role: IdentifierString) -> Result<Self, Error>
Creates a new CustomRole
instance.
§Errors
Returns an error if the role
starts with the string “trust-anchor-”.
This prefix is disallowed to avoid overlaps with Mode::TrustAnchor
.
Sourcepub fn parser(input: &mut &str) -> ModalResult<Self>
pub fn parser(input: &mut &str) -> ModalResult<Self>
Recognizes a CustomRole
in a string slice.
Consumes all of its input
.
§Errors
Returns an error if
input
starts with the string representation ofMode::TrustAnchor
,- or one of the characters in
input
is not covered byIdentifierString::valid_chars
.
§Examples
use voa_core::identifiers::CustomRole;
use winnow::Parser;
assert_eq!(CustomRole::parser.parse("test")?.to_string(), "test");
assert_eq!(
CustomRole::parser
.parse("something-very-special")?
.to_string(),
"something-very-special"
);
assert_eq!(
CustomRole::parser
.parse("something-very-trust-anchor")?
.to_string(),
"something-very-trust-anchor"
);
assert!(CustomRole::parser.parse("trust-anchor").is_err());
assert!(CustomRole::parser.parse("trust-anchor-test").is_err());
Trait Implementations§
Source§impl Clone for CustomRole
impl Clone for CustomRole
Source§fn clone(&self) -> CustomRole
fn clone(&self) -> CustomRole
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for CustomRole
impl Debug for CustomRole
Source§impl Display for CustomRole
impl Display for CustomRole
Source§impl From<CustomRole> for Role
impl From<CustomRole> for Role
Source§fn from(val: CustomRole) -> Self
fn from(val: CustomRole) -> Self
Converts to this type from the input type.
Source§impl FromStr for CustomRole
impl FromStr for CustomRole
Source§fn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
Creates a new CustomRole
from a string slice.
§Errors
Returns an error if either IdentifierString::from_str
or CustomRole::new
fail.
Source§impl PartialEq for CustomRole
impl PartialEq for CustomRole
Source§impl Serialize for CustomRole
impl Serialize for CustomRole
impl StructuralPartialEq for CustomRole
Auto Trait Implementations§
impl Freeze for CustomRole
impl RefUnwindSafe for CustomRole
impl Send for CustomRole
impl Sync for CustomRole
impl Unpin for CustomRole
impl UnwindSafe for CustomRole
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