TokenStore

Trait TokenStore 

Source
pub trait TokenStore<'a>: Sized {
    type Item: Deref<Target = Token>;

    // Required methods
    fn get(&'a self, chain_id: u64, id: TokenId) -> Option<Self::Item>;
    fn get_mut(&mut self, chain_id: u64, id: TokenId) -> Option<&mut Token>;
    fn insert(&mut self, chain_id: u64, token: Token);
    fn contains(&self, chain_id: u64, id: TokenId) -> bool;
    fn symbols(&'a self, chain_id: Option<u64>) -> Vec<String>;
    fn addresses(&'a self, chain_id: Option<u64>) -> Vec<Address>;

    // Provided methods
    fn entry(&'a mut self, chain_id: u64, id: TokenId) -> Entry<'a, Self> { ... }
    fn iter(&'a self, chain_id: u64) -> StoreIter<'a, Self>  { ... }
}
Expand description

A Token store

Required Associated Types§

Source

type Item: Deref<Target = Token>

a reference to a token.

Required Methods§

Source

fn get(&'a self, chain_id: u64, id: TokenId) -> Option<Self::Item>

Returns the value corresponding to the given id.

Source

fn get_mut(&mut self, chain_id: u64, id: TokenId) -> Option<&mut Token>

Returns the mutable value corresponding to the given id.

Source

fn insert(&mut self, chain_id: u64, token: Token)

Inserts a token into the store.

Source

fn contains(&self, chain_id: u64, id: TokenId) -> bool

Returns true if the store contains a value for the specified id.

Source

fn symbols(&'a self, chain_id: Option<u64>) -> Vec<String>

Returns the symbols from all the tokens in the store.

Source

fn addresses(&'a self, chain_id: Option<u64>) -> Vec<Address>

Returns the addresses from all the tokens in the store.

Provided Methods§

Source

fn entry(&'a mut self, chain_id: u64, id: TokenId) -> Entry<'a, Self>

Gets the entry for the given token id.

Source

fn iter(&'a self, chain_id: u64) -> StoreIter<'a, Self>

Returns an iterator over the store’s tokens.

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§