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§
Sourcefn get(
&self,
id: ChainId,
) -> impl Future<Output = Result<Option<Chain>, Self::Error>> + Send
fn get( &self, id: ChainId, ) -> impl Future<Output = Result<Option<Chain>, Self::Error>> + Send
Returns the state of the chain with the given ID, if it is tracked.
Sourcefn remove(
&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
Removes the chain with the given ID, returning its previous state if any.
Sourcefn items(
&self,
) -> impl Stream<Item = Result<(ChainId, Chain), Self::Error>> + Send
fn items( &self, ) -> impl Stream<Item = Result<(ChainId, Chain), Self::Error>> + Send
Returns a stream over all tracked chains and their states.
Sourcefn insert(
&self,
id: ChainId,
chain: Chain,
) -> impl Future<Output = Result<Option<Chain>, Self::Error>> + Send
fn insert( &self, id: ChainId, chain: Chain, ) -> impl Future<Output = Result<Option<Chain>, Self::Error>> + Send
Inserts or replaces the state of the given chain, returning the previous state if any.
Sourcefn try_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
Inserts the given chain only if it is not already tracked, returning the existing state otherwise.
Sourcefn modify(
&self,
id: ChainId,
f: impl Fn(&mut Chain) + Send,
) -> impl Future<Output = Result<Option<()>, Self::Error>> + Send
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§
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.