[−][src]Struct commodity::Currency
Represents a the type of currency held in a Commodity. See CurrencyCode for the primative which is genarally stored and used to refer to a given Currency.
Fields
code: CurrencyCode
Stores the code/id of this currency in a fixed length ArrayString, with a maximum length of CURRENCY_CODE_LENGTH.
name: Option<String>
The human readable name of this currency.
Methods
impl Currency
[src]
pub fn new(code: CurrencyCode, name: Option<String>) -> Currency
[src]
Create a new Currency
Example
use std::str::FromStr; let code = CurrencyCode::from_str("AUD").unwrap(); let currency = Currency::new( code, Some(String::from("Australian Dollar")) ); assert_eq!(code, currency.code); assert_eq!(Some(String::from("Australian Dollar")), currency.name);
pub fn from_str(code: &str, name: &str) -> Result<Currency, CommodityError>
[src]
Create a Currency from strings, usually for debugging, or unit testing purposes.
code
is an array backed string that has a fixed maximum size
of CURRENCY_CODE_LENGTH. The supplied
string must not exeed this, or a
CommodityError::TooLongCurrencyCode
will be returned.
Example
use std::str::FromStr; let currency = Currency::from_str("AUD", "Australian dollar").unwrap(); assert_eq!(CurrencyCode::from_str("AUD").unwrap(), currency.code); assert_eq!("Australian dollar", currency.name.unwrap());
pub fn from_alpha3(alpha3: &str) -> Result<Currency, CommodityError>
[src]
Trait Implementations
impl Clone for Currency
[src]
impl Debug for Currency
[src]
impl<'_> From<&'_ Currency> for CurrencyCode
[src]
fn from(currency: &Currency) -> CurrencyCode
[src]
Auto Trait Implementations
impl RefUnwindSafe for Currency
impl Send for Currency
impl Sync for Currency
impl Unpin for Currency
impl UnwindSafe for Currency
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,