pub struct OpaqueString(/* private fields */);
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§

source§

impl OpaqueString

source

pub fn new() -> Self

Creates a OpaqueString profile.

Trait Implementations§

source§

impl Clone for OpaqueString

source§

fn clone(&self) -> OpaqueString

Returns a copy 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 OpaqueString

source§

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

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

impl Default for OpaqueString

source§

fn default() -> OpaqueString

Returns the “default value” for a type. Read more
source§

impl PartialEq for OpaqueString

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PrecisFastInvocation for OpaqueString

source§

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
source§

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
source§

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.
source§

impl Profile for OpaqueString

source§

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
source§

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
source§

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.
source§

impl Rules for OpaqueString

source§

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
source§

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
source§

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
source§

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
source§

fn directionality_rule<'a, T>(&self, _s: T) -> Result<Cow<'a, str>, Error>
where T: Into<Cow<'a, str>>,

Applies the directionality rule of a profile to an input string Read more
source§

impl Copy for OpaqueString

source§

impl Eq for OpaqueString

source§

impl StructuralEq for OpaqueString

source§

impl StructuralPartialEq for OpaqueString

Auto Trait Implementations§

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> 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,

§

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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.