pub struct CurrencyCode(/* private fields */);Expand description
ISO 4217 three-letter currency code.
Stored as 3 ASCII uppercase bytes for zero-allocation comparisons and copies.
§Example
use stateset_primitives::CurrencyCode;
let usd = CurrencyCode::USD;
assert_eq!(usd.as_str(), "USD");
let parsed: CurrencyCode = "EUR".parse().unwrap();
assert_eq!(parsed, CurrencyCode::EUR);Implementations§
Source§impl CurrencyCode
impl CurrencyCode
Sourcepub const USD: CurrencyCode
pub const USD: CurrencyCode
United States Dollar
Sourcepub const EUR: CurrencyCode
pub const EUR: CurrencyCode
Euro
Sourcepub const GBP: CurrencyCode
pub const GBP: CurrencyCode
British Pound Sterling
Sourcepub const JPY: CurrencyCode
pub const JPY: CurrencyCode
Japanese Yen
Sourcepub const CAD: CurrencyCode
pub const CAD: CurrencyCode
Canadian Dollar
Sourcepub const AUD: CurrencyCode
pub const AUD: CurrencyCode
Australian Dollar
Sourcepub const CHF: CurrencyCode
pub const CHF: CurrencyCode
Swiss Franc
Sourcepub const CNY: CurrencyCode
pub const CNY: CurrencyCode
Chinese Yuan
Sourcepub const fn from_bytes(bytes: [u8; 3]) -> Option<CurrencyCode>
pub const fn from_bytes(bytes: [u8; 3]) -> Option<CurrencyCode>
Create a currency code from 3 ASCII uppercase bytes.
Returns None if any byte is not ASCII uppercase.
Trait Implementations§
Source§impl Clone for CurrencyCode
impl Clone for CurrencyCode
Source§fn clone(&self) -> CurrencyCode
fn clone(&self) -> CurrencyCode
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for CurrencyCode
Source§impl Debug for CurrencyCode
impl Debug for CurrencyCode
Source§impl Default for CurrencyCode
impl Default for CurrencyCode
Source§fn default() -> CurrencyCode
fn default() -> CurrencyCode
Defaults to USD — the most common commerce currency.
Source§impl<'de> Deserialize<'de> for CurrencyCode
impl<'de> Deserialize<'de> for CurrencyCode
Source§fn deserialize<D>(
deserializer: D,
) -> Result<CurrencyCode, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<CurrencyCode, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for CurrencyCode
impl Display for CurrencyCode
impl Eq for CurrencyCode
Source§impl FromStr for CurrencyCode
impl FromStr for CurrencyCode
Source§type Err = CurrencyCodeError
type Err = CurrencyCodeError
The associated error which can be returned from parsing.
Source§fn from_str(s: &str) -> Result<CurrencyCode, <CurrencyCode as FromStr>::Err>
fn from_str(s: &str) -> Result<CurrencyCode, <CurrencyCode as FromStr>::Err>
Parses a string
s to return a value of this type. Read moreSource§impl Hash for CurrencyCode
impl Hash for CurrencyCode
Source§impl Ord for CurrencyCode
impl Ord for CurrencyCode
Source§fn cmp(&self, other: &CurrencyCode) -> Ordering
fn cmp(&self, other: &CurrencyCode) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for CurrencyCode
impl PartialEq for CurrencyCode
Source§impl PartialOrd for CurrencyCode
impl PartialOrd for CurrencyCode
Source§impl Serialize for CurrencyCode
impl Serialize for CurrencyCode
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for CurrencyCode
Auto Trait Implementations§
impl Freeze for CurrencyCode
impl RefUnwindSafe for CurrencyCode
impl Send for CurrencyCode
impl Sync for CurrencyCode
impl Unpin for CurrencyCode
impl UnsafeUnpin for CurrencyCode
impl UnwindSafe for CurrencyCode
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