Trait Currency

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

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

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

Required Associated Constants§

const NAME: &'static str

Name of the currency.

const SCALE: usize

Base unit exponent used for the currency.

Provided Methods§

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

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

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§

§

impl Currency for WxHOPR

§

const NAME: &'static str = "wxHOPR"

§

const SCALE: usize = 18usize

§

impl Currency for XDai

§

const NAME: &'static str = "xDai"

§

const SCALE: usize = 18usize