Trait Currency

Source
pub trait Currency:
    Display
    + FromStr<Err = GeneralError>
    + Default
    + PartialEq
    + Eq {
    const NAME: &'static str;
    const SCALE: usize;

    // Provided methods
    fn is<C: Currency>() -> bool { ... }
    fn name_matches(s: &str) -> Result<(), GeneralError> { ... }
}
Expand description

Represents a general currency - like a token or a coin.

Required Associated Constants§

Source

const NAME: &'static str

Name of the currency.

Source

const SCALE: usize

Base unit exponent used for the currency.

Provided Methods§

Source

fn is<C: Currency>() -> bool

Checks if this currency is the same as the one given in the template argument.

Source

fn name_matches(s: &str) -> Result<(), GeneralError>

Returns Ok(()) if the given string is equal to the currency name.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Currency for WxHOPR

Source§

const NAME: &'static str = "wxHOPR"

Source§

const SCALE: usize = 18usize

Source§

impl Currency for XDai

Source§

const NAME: &'static str = "xDai"

Source§

const SCALE: usize = 18usize