Trait Wallet

Source
pub trait Wallet: Send {
    type Error: Error + Send + Sync;

    // Required methods
    fn get(
        &self,
        id: ChainId,
    ) -> impl Future<Output = Result<Option<Chain>, Self::Error>> + Send;
    fn remove(
        &self,
        id: ChainId,
    ) -> impl Future<Output = Result<Option<Chain>, Self::Error>> + Send;
    fn items(
        &self,
    ) -> impl Stream<Item = Result<(ChainId, Chain), Self::Error>> + Send;
    fn insert(
        &self,
        id: ChainId,
        chain: Chain,
    ) -> impl Future<Output = Result<Option<Chain>, Self::Error>> + Send;
    fn try_insert(
        &self,
        id: ChainId,
        chain: Chain,
    ) -> impl Future<Output = Result<Option<Chain>, Self::Error>> + Send;
    fn modify(
        &self,
        id: ChainId,
        f: impl Fn(&mut Chain) + Send,
    ) -> impl Future<Output = Result<Option<()>, Self::Error>> + Send;

    // Provided methods
    fn chain_ids(
        &self,
    ) -> impl Stream<Item = Result<ChainId, Self::Error>> + Send { ... }
    fn owned_chain_ids(
        &self,
    ) -> impl Stream<Item = Result<ChainId, Self::Error>> + Send { ... }
}
Expand description

A trait for the wallet (i.e. set of chain states) tracked by the client.

Required Associated Types§

Required Methods§

Source

fn get( &self, id: ChainId, ) -> impl Future<Output = Result<Option<Chain>, Self::Error>> + Send

Source

fn remove( &self, id: ChainId, ) -> impl Future<Output = Result<Option<Chain>, Self::Error>> + Send

Source

fn items( &self, ) -> impl Stream<Item = Result<(ChainId, Chain), Self::Error>> + Send

Source

fn insert( &self, id: ChainId, chain: Chain, ) -> impl Future<Output = Result<Option<Chain>, Self::Error>> + Send

Source

fn try_insert( &self, id: ChainId, chain: Chain, ) -> impl Future<Output = Result<Option<Chain>, Self::Error>> + Send

Source

fn modify( &self, id: ChainId, f: impl Fn(&mut Chain) + Send, ) -> impl Future<Output = Result<Option<()>, Self::Error>> + Send

Modifies a chain in the wallet. Returns Ok(None) if the chain doesn’t exist.

The closure may be called more than once (e.g. on CAS contention), so it must be idempotent. Fn (not FnMut) is required to discourage reliance on mutable captured state.

Provided Methods§

Source

fn chain_ids(&self) -> impl Stream<Item = Result<ChainId, Self::Error>> + Send

Source

fn owned_chain_ids( &self, ) -> impl Stream<Item = Result<ChainId, Self::Error>> + Send

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§