Struct precis_profiles::UsernameCaseMapped
source · [−]pub struct UsernameCaseMapped(_);Expand description
UsernameCaseMapped.
Profile designed to deal with usernames in security and application protocols.
It replaces the SASLprep profile of Stringprep. Look at the
IANA Considerations
section for more details.
Example
// create UsernameCaseMapped profile
let profile = UsernameCaseMapped::new();
// prepare string
assert_eq!(profile.prepare("Guybrush"), Ok(Cow::from("Guybrush")));
// UsernameCaseMapped does not accept spaces. Unicode code point 0x0020
assert_eq!(profile.prepare("Guybrush Threepwood"),
Err(Error::BadCodepoint(CodepointInfo { cp: 0x0020, position: 8, property: DerivedPropertyValue::SpecClassDis })));
// enforce string
assert_eq!(profile.enforce("Guybrush"), Ok(Cow::from("guybrush")));
// compare strings
assert_eq!(profile.compare("Guybrush", "guybrush"), Ok(true));Implementations
sourceimpl UsernameCaseMapped
impl UsernameCaseMapped
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a UsernameCaseMapped profile.
Trait Implementations
sourceimpl Clone for UsernameCaseMapped
impl Clone for UsernameCaseMapped
sourcefn clone(&self) -> UsernameCaseMapped
fn clone(&self) -> UsernameCaseMapped
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl Debug for UsernameCaseMapped
impl Debug for UsernameCaseMapped
sourceimpl Default for UsernameCaseMapped
impl Default for UsernameCaseMapped
sourcefn default() -> UsernameCaseMapped
fn default() -> UsernameCaseMapped
Returns the “default value” for a type. Read more
sourceimpl PartialEq<UsernameCaseMapped> for UsernameCaseMapped
impl PartialEq<UsernameCaseMapped> for UsernameCaseMapped
sourcefn eq(&self, other: &UsernameCaseMapped) -> bool
fn eq(&self, other: &UsernameCaseMapped) -> bool
This method tests for self and other values to be equal, and is used
by ==. Read more
sourcefn ne(&self, other: &UsernameCaseMapped) -> bool
fn ne(&self, other: &UsernameCaseMapped) -> bool
This method tests for !=.
sourceimpl PrecisFastInvocation for UsernameCaseMapped
impl PrecisFastInvocation for UsernameCaseMapped
sourcefn prepare<'a, S>(s: S) -> Result<Cow<'a, str>, Error> where
S: Into<Cow<'a, str>>,
fn prepare<'a, S>(s: S) -> Result<Cow<'a, str>, Error> where
S: Into<Cow<'a, str>>,
Ensures that the code points in a single input string are allowed by the underlying PRECIS string class, and sometimes also entails applying one or more of the rules specified for a particular string class or profile thereof. Read more
sourcefn enforce<'a, S>(s: S) -> Result<Cow<'a, str>, Error> where
S: Into<Cow<'a, str>>,
fn enforce<'a, S>(s: S) -> Result<Cow<'a, str>, Error> where
S: Into<Cow<'a, str>>,
Applies all rules specified for a particular string class, or profile thereof, to a single input string, for the purpose of checking whether the string conforms to all the rules and thus determining if the string can be used in a given protocol slot. Read more
sourcefn compare<A, B>(s1: A, s2: B) -> Result<bool, Error> where
A: AsRef<str>,
B: AsRef<str>,
fn compare<A, B>(s1: A, s2: B) -> Result<bool, Error> where
A: AsRef<str>,
B: AsRef<str>,
Comparison entails applying all the rules specified for a particular string class, or profile thereof, to two separate input strings, for the purpose of determining if the two strings are equivalent. Read more
sourceimpl Profile for UsernameCaseMapped
impl Profile for UsernameCaseMapped
sourcefn prepare<'a, S>(&self, s: S) -> Result<Cow<'a, str>, Error> where
S: Into<Cow<'a, str>>,
fn prepare<'a, S>(&self, s: S) -> Result<Cow<'a, str>, Error> where
S: Into<Cow<'a, str>>,
Ensures that the code points in a single input string are allowed by the underlying PRECIS string class, and sometimes also entails applying one or more of the rules specified for a particular string class or profile thereof. Read more
sourcefn enforce<'a, S>(&self, s: S) -> Result<Cow<'a, str>, Error> where
S: Into<Cow<'a, str>>,
fn enforce<'a, S>(&self, s: S) -> Result<Cow<'a, str>, Error> where
S: Into<Cow<'a, str>>,
Applies all the rules specified for a particular string class, or profile thereof, to a single input string, for the purpose of checking whether the string conforms to all the rules and thus determining if the string can be used in a given protocol slot. Read more
sourcefn compare<A, B>(&self, s1: A, s2: B) -> Result<bool, Error> where
A: AsRef<str>,
B: AsRef<str>,
fn compare<A, B>(&self, s1: A, s2: B) -> Result<bool, Error> where
A: AsRef<str>,
B: AsRef<str>,
Comparison entails applying all the rules specified for a particular string class, or profile thereof, to two separate input strings, for the purpose of determining if the two strings are equivalent. Read more
sourceimpl Rules for UsernameCaseMapped
impl Rules for UsernameCaseMapped
sourcefn width_mapping_rule<'a, T>(&self, s: T) -> Result<Cow<'a, str>, Error> where
T: Into<Cow<'a, str>>,
fn width_mapping_rule<'a, T>(&self, s: T) -> Result<Cow<'a, str>, Error> where
T: Into<Cow<'a, str>>,
Applies the width mapping rule of a profile to an input string. Read more
sourcefn case_mapping_rule<'a, T>(&self, s: T) -> Result<Cow<'a, str>, Error> where
T: Into<Cow<'a, str>>,
fn case_mapping_rule<'a, T>(&self, s: T) -> Result<Cow<'a, str>, Error> where
T: Into<Cow<'a, str>>,
Applies the case mapping rule of a profile to an input string Read more
sourcefn normalization_rule<'a, T>(&self, s: T) -> Result<Cow<'a, str>, Error> where
T: Into<Cow<'a, str>>,
fn normalization_rule<'a, T>(&self, s: T) -> Result<Cow<'a, str>, Error> where
T: Into<Cow<'a, str>>,
Applies the normalization rule of a profile to an input string Read more
impl Copy for UsernameCaseMapped
impl Eq for UsernameCaseMapped
impl StructuralEq for UsernameCaseMapped
impl StructuralPartialEq for UsernameCaseMapped
Auto Trait Implementations
impl RefUnwindSafe for UsernameCaseMapped
impl Send for UsernameCaseMapped
impl Sync for UsernameCaseMapped
impl Unpin for UsernameCaseMapped
impl UnwindSafe for UsernameCaseMapped
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more