Struct precis_profiles::OpaqueString [−][src]
pub struct OpaqueString { /* fields omitted */ }Expand description
OpaqueString Profile 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
use precis_core::Error;
use precis_core::profile::Profile;
use precis_profiles::OpaqueString;
use std::borrow::Cow;
// 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
Trait Implementations
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
Applies all of 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 of the rules and thus determining if the string can be used in a given protocol slot. Read more