Struct wow_srp::normalized_string::NormalizedString
source · pub struct NormalizedString { /* private fields */ }
Expand description
Represents usernames and passwords containing only allowed characters.
See module normalized_string
for more information.
The NormalizedString::new
method will always take the format that requires the
least amount of translation to the underlying string format.
This method can change interface completely without it being a breaking change.
This is done deliberately in order to alert users of changes that could impact performance.
Iif you want stability Use the NormalizedString::from_string
or NormalizedString::from_str
.
use wow_srp::error::NormalizedStringError;
use wow_srp::normalized_string::NormalizedString;
// From &str
let username = "Alice";
let username: NormalizedString = username.try_into()?;
// From string
let password = String::from("hunter2");
let password: NormalizedString = password.try_into()?;
Implementations§
source§impl NormalizedString
impl NormalizedString
sourcepub fn new(s: impl AsRef<str>) -> Result<Self, NormalizedStringError>
pub fn new(s: impl AsRef<str>) -> Result<Self, NormalizedStringError>
Checks for non-ASCII characters and too large of a string and correctly uppercases letters as needed.
Allowed characters are all ASCII characters except for ASCII control characters.
§Errors
See the module level docs for explanation of allowed values.
sourcepub fn from_str(s: impl AsRef<str>) -> Result<Self, NormalizedStringError>
pub fn from_str(s: impl AsRef<str>) -> Result<Self, NormalizedStringError>
Checks for non-ASCII characters and too large of a string and correctly uppercases letters as needed.
Allowed characters are all ASCII characters except for ASCII control characters.
§Errors
See the module level docs for explanation of allowed values.
sourcepub fn from_string(s: impl Into<String>) -> Result<Self, NormalizedStringError>
pub fn from_string(s: impl Into<String>) -> Result<Self, NormalizedStringError>
Checks for non-ASCII characters and too large of a string and correctly uppercases letters as needed.
Allowed characters are all ASCII characters except for ASCII control characters.
§Errors
See the module level docs for explanation of allowed values.
Trait Implementations§
source§impl AsRef<str> for NormalizedString
impl AsRef<str> for NormalizedString
source§impl Clone for NormalizedString
impl Clone for NormalizedString
source§fn clone(&self) -> NormalizedString
fn clone(&self) -> NormalizedString
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for NormalizedString
impl Debug for NormalizedString
source§impl Display for NormalizedString
impl Display for NormalizedString
source§impl Hash for NormalizedString
impl Hash for NormalizedString
source§impl Ord for NormalizedString
impl Ord for NormalizedString
source§fn cmp(&self, other: &NormalizedString) -> Ordering
fn cmp(&self, other: &NormalizedString) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq for NormalizedString
impl PartialEq for NormalizedString
source§fn eq(&self, other: &NormalizedString) -> bool
fn eq(&self, other: &NormalizedString) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for NormalizedString
impl PartialOrd for NormalizedString
source§fn partial_cmp(&self, other: &NormalizedString) -> Option<Ordering>
fn partial_cmp(&self, other: &NormalizedString) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more