Struct precis_profiles::UsernameCasePreserved [−][src]
pub struct UsernameCasePreserved { /* fields omitted */ }Expand description
UsernameCasePreserved.
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
use precis_core::Error;
use precis_core::{CodepointInfo, DerivedPropertyValue};
use precis_core::profile::Profile;
use precis_profiles::UsernameCasePreserved;
use std::borrow::Cow;
// create UsernameCasePreserved profile
let profile = UsernameCasePreserved::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
Creates a UsernameCasePreserved profile.
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 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
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 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