#[non_exhaustive]pub enum CountryCodeError {
Empty,
InvalidLength {
found: usize,
},
InvalidCharacter {
character: char,
position: u8,
},
Unassigned {
code: [char; 2],
},
}Expand description
The set of reasons a country code string can fail validation.
Every fallible constructor of CountryCode returns this type. A country
code carries no checksum. Its validity is defined by membership in the officially assigned ISO
3166-1 alpha-2 set, so beyond the structural checks there is one assignment failure mode
(CountryCodeError::Unassigned). Each variant maps to a single, specific failure, so callers
can react programmatically rather than parsing a message.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Empty
The input was an empty string.
InvalidLength
After trimming surrounding whitespace, the input did not contain exactly two characters.
InvalidCharacter
A character outside A to Z was found at a given position. Every position of a country
code is an uppercase ASCII letter.
Fields
Unassigned
The two letters are well formed but are not a code that ISO 3166-1 officially assigns.
Trait Implementations§
Source§impl Clone for CountryCodeError
impl Clone for CountryCodeError
Source§fn clone(&self) -> CountryCodeError
fn clone(&self) -> CountryCodeError
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 CountryCodeError
impl Debug for CountryCodeError
Source§impl Display for CountryCodeError
impl Display for CountryCodeError
impl Eq for CountryCodeError
Source§impl Error for CountryCodeError
impl Error for CountryCodeError
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()