pub struct Alpha2(/* private fields */);Expand description
A wrapper around the numeric enumeration requiring strings be Alpha-2 format.
When the serde feature is enabled, this type will be serialized as the Alpha-2 string.
Implementations§
Source§impl Alpha2
impl Alpha2
Sourcepub const fn from_alpha2(s: &str) -> Result<Self, Error>
pub const fn from_alpha2(s: &str) -> Result<Self, Error>
Create a new value from an Alpha2 string.
§Errors
Error::InvalidLengthif the given slice is not 2 characters.Error::InvalidCharsetif the given slice does not contain ASCII characters.Error::UnknownStringif the given slice does not match any known Alpha2 code.
Sourcepub const fn from_u16(value: u16) -> Result<Self, Error>
pub const fn from_u16(value: u16) -> Result<Self, Error>
Create a new value from an unsigned integer.
§Errors
Error::UnknownCodeif the given code value is not a numeric code.
Sourcepub const fn from_alpha3(value: Alpha3) -> Self
pub const fn from_alpha3(value: Alpha3) -> Self
Create a new value from an Alpha3 code.
Sourcepub const fn from_numeric(value: Numeric) -> Self
pub const fn from_numeric(value: Numeric) -> Self
Create a new value from a numeric code.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Alpha2
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Alpha2
Available on crate feature
serde only.Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Ord for Alpha2
impl Ord for Alpha2
Source§impl PartialOrd for Alpha2
impl PartialOrd for Alpha2
impl Copy for Alpha2
impl Eq for Alpha2
impl StructuralPartialEq for Alpha2
Auto Trait Implementations§
impl Freeze for Alpha2
impl RefUnwindSafe for Alpha2
impl Send for Alpha2
impl Sync for Alpha2
impl Unpin for Alpha2
impl UnwindSafe for Alpha2
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more