[−][src]Struct commodity::CommodityType
Represents a type of Commodity.
See CommodityTypeID for the primative which is genarally stored and used to refer to a given CommodityType.
Fields
id: CommodityTypeID
Stores the id of this commodity type in a fixed length ArrayString, with a maximum length of COMMODITY_TYPE_ID_LENGTH.
name: Option<String>
The human readable name of this commodity_type.
Methods
impl CommodityType
[src]
pub fn new(id: CommodityTypeID, name: Option<String>) -> CommodityType
[src]
Create a new CommodityType.
Example
use std::str::FromStr; let id = CommodityTypeID::from_str("AUD").unwrap(); let commodity_type = CommodityType::new( id, Some(String::from("Australian Dollar")) ); assert_eq!(id, commodity_type.id); assert_eq!(Some(String::from("Australian Dollar")), commodity_type.name);
pub fn from_str<SR: AsRef<str>, SI: Into<String>>(
id: SR,
name: SI
) -> Result<CommodityType, CommodityError>
[src]
id: SR,
name: SI
) -> Result<CommodityType, CommodityError>
Create a CommodityType from strings, usually for debugging, or unit testing purposes.
id
is an array backed string that has a fixed maximum size
of COMMODITY_TYPE_ID_LENGTH. The supplied
string must not exeed this, or a
CommodityError::TooLongCommodityTypeID
will be returned.
Example
use std::str::FromStr; let commodity_type = CommodityType::from_str("AUD", "Australian dollar").unwrap(); assert_eq!(CommodityTypeID::from_str("AUD").unwrap(), commodity_type.id); assert_eq!("Australian dollar", commodity_type.name.unwrap());
pub fn from_currency_alpha3<S: AsRef<str>>(
alpha3: S
) -> Result<CommodityType, CommodityError>
[src]
alpha3: S
) -> Result<CommodityType, CommodityError>
Construct a CommodityType by looking it up in the ISO4217
currencies database.
Example
let commodity_type = CommodityType::from_currency_alpha3("AUD").unwrap(); assert_eq!("AUD", commodity_type.id); assert_eq!(Some(String::from("Australian dollar")), commodity_type.name);
Trait Implementations
impl Clone for CommodityType
[src]
fn clone(&self) -> CommodityType
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for CommodityType
[src]
impl<'de> Deserialize<'de> for CommodityType
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Display for CommodityType
[src]
impl<'_> From<&'_ CommodityType> for CommodityTypeID
[src]
fn from(commodity_type: &CommodityType) -> CommodityTypeID
[src]
impl PartialEq<CommodityType> for CommodityType
[src]
This implementation only checks that the ids match. It assumes that you will not have logical different commodity types with the same id but different names.
impl Serialize for CommodityType
[src]
Auto Trait Implementations
impl RefUnwindSafe for CommodityType
impl Send for CommodityType
impl Sync for CommodityType
impl Unpin for CommodityType
impl UnwindSafe for CommodityType
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> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
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> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
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>,