Struct precis_profiles::OpaqueString
source · [−]pub struct OpaqueString(_);Expand description
OpaqueString
Profile designed to deal with passwords and other opaque strings in security
and application protocols.
Replaces: The SASLprep profile of Stringprep. Look at the
IANA Considerations
section for more details.
Example
// create OpaqueString profile
let profile = OpaqueString::new();
// prepare string
assert_eq!(profile.prepare("I'm Guybrush Threepwood, Mighty Pirate ☠"),
Ok(Cow::from("I'm Guybrush Threepwood, Mighty Pirate ☠")));
// enforce string
assert_eq!(profile.enforce("Look behind you, a three-headed monkey!🐒"),
Ok(Cow::from("Look behind you, a three-headed monkey!🐒")));
// compare strings
assert_eq!(profile.compare("That’s the second biggest 🐵 I’ve ever seen!",
"That’s the second biggest 🐵 I’ve ever seen!"), Ok(true));Implementations
sourceimpl OpaqueString
impl OpaqueString
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a OpaqueString profile.
Trait Implementations
sourceimpl Clone for OpaqueString
impl Clone for OpaqueString
sourcefn clone(&self) -> OpaqueString
fn clone(&self) -> OpaqueString
Returns a copy of the value. Read more
1.0.0 · sourceconst fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresourceimpl Debug for OpaqueString
impl Debug for OpaqueString
sourceimpl Default for OpaqueString
impl Default for OpaqueString
sourcefn default() -> OpaqueString
fn default() -> OpaqueString
Returns the “default value” for a type. Read more
sourceimpl PartialEq<OpaqueString> for OpaqueString
impl PartialEq<OpaqueString> for OpaqueString
sourcefn eq(&self, other: &OpaqueString) -> bool
fn eq(&self, other: &OpaqueString) -> bool
sourceimpl PrecisFastInvocation for OpaqueString
impl PrecisFastInvocation for OpaqueString
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 OpaqueString
impl Profile for OpaqueString
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 OpaqueString
impl Rules for OpaqueString
sourcefn additional_mapping_rule<'a, T>(&self, s: T) -> Result<Cow<'a, str>, Error>where
T: Into<Cow<'a, str>>,
fn additional_mapping_rule<'a, T>(&self, s: T) -> Result<Cow<'a, str>, Error>where
T: Into<Cow<'a, str>>,
Applies the additional 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
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
impl Copy for OpaqueString
impl Eq for OpaqueString
impl StructuralEq for OpaqueString
impl StructuralPartialEq for OpaqueString
Auto Trait Implementations
impl RefUnwindSafe for OpaqueString
impl Send for OpaqueString
impl Sync for OpaqueString
impl Unpin for OpaqueString
impl UnwindSafe for OpaqueString
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
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