#[non_exhaustive]pub enum UsernameError {
Empty,
TooLong {
len: usize,
max: usize,
},
AddressShaped,
ControlCharacter,
}Expand description
Why a username string was rejected by Username::from_str.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Empty
The username is empty, or is nothing but whitespace.
Whitespace-only is refused here rather than treated as a name: a claim nobody can type back, and that renders as nothing at all in every UI, is not a name. Note that normalization does not remove it — NFC discards nothing — so this is a screen, not a consequence of one.
TooLong
The normalized username exceeds Username::MAX_BYTES.
Measured after normalization, since that is the form that gets published, hashed and signed.
AddressShaped
The username has the shape of an Address.
Refused at the type rather than at publish time so no caller can skip the screen. Two namespaces that never share a spelling cannot be confused by a UI that renders both, and a claim on an address-shaped name has no legitimate use.
ControlCharacter
The username contains a control or format character.
A name that can contain a newline or a bidi override is a name that renders as something other than itself in every UI that displays it.
Both Unicode Cc (control) and Cf (format) are refused, and the
second is the one that matters: char::is_control covers only Cc, so
a screen built on it alone lets through U+202E RIGHT-TO-LEFT OVERRIDE
and the zero-width joiners — exactly the characters that make a name
display as something other than its own bytes. Confusables between
scripts remain out of scope (see the module docs); characters whose
entire function is to alter rendering are not.
Trait Implementations§
Source§impl Clone for UsernameError
impl Clone for UsernameError
Source§fn clone(&self) -> UsernameError
fn clone(&self) -> UsernameError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for UsernameError
impl Debug for UsernameError
Source§impl Display for UsernameError
impl Display for UsernameError
impl Eq for UsernameError
Source§impl Error for UsernameError
impl Error for UsernameError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()