Trait Bank

Source
pub trait Bank<K> {
    type Num;

    // Required methods
    fn record_transferred_in_by_token<Q: Borrow<K> + ?Sized>(
        &mut self,
        token: &Q,
        amount: &Self::Num,
    ) -> Result<()>;
    fn record_transferred_out_by_token<Q: Borrow<K> + ?Sized>(
        &mut self,
        token: &Q,
        amount: &Self::Num,
    ) -> Result<()>;
    fn balance<Q: Borrow<K> + ?Sized>(&self, token: &Q) -> Result<Self::Num>;

    // Provided method
    fn balance_excluding<Q: Borrow<K> + ?Sized>(
        &self,
        token: &Q,
        excluded: &Self::Num,
    ) -> Result<Self::Num>
       where Self::Num: CheckedSub + Zero { ... }
}
Expand description

A bank of tokens.

Required Associated Types§

Source

type Num

Number type.

Required Methods§

Source

fn record_transferred_in_by_token<Q: Borrow<K> + ?Sized>( &mut self, token: &Q, amount: &Self::Num, ) -> Result<()>

Record transferred in amount by token.

Source

fn record_transferred_out_by_token<Q: Borrow<K> + ?Sized>( &mut self, token: &Q, amount: &Self::Num, ) -> Result<()>

Record transferred out amount by token.

Source

fn balance<Q: Borrow<K> + ?Sized>(&self, token: &Q) -> Result<Self::Num>

Get the balance of the given token.

Provided Methods§

Source

fn balance_excluding<Q: Borrow<K> + ?Sized>( &self, token: &Q, excluded: &Self::Num, ) -> Result<Self::Num>
where Self::Num: CheckedSub + Zero,

Get the balance of the given token excluding excluded amount.

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§