Skip to main content

StateSource

Trait StateSource 

Source
pub trait StateSource: Send + Sync {
    type Error: Error + Send + 'static;

    // Required method
    fn account_details(
        &self,
        address: &Address,
    ) -> impl Future<Output = Result<AcctInfo, Self::Error>> + Send;

    // Provided methods
    fn nonce(
        &self,
        address: &Address,
    ) -> impl Future<Output = Result<u64, Self::Error>> + Send { ... }
    fn balance(
        &self,
        address: &Address,
    ) -> impl Future<Output = Result<U256, Self::Error>> + Send { ... }
    fn map<T: Send, F: FnOnce(&AcctInfo) -> T + Send>(
        &self,
        address: &Address,
        f: F,
    ) -> impl Future<Output = Result<T, Self::Error>> + Send { ... }
}
Expand description

A source for nonce and balance information. Exists to simplify type bounds in various places.

Required Associated Types§

Source

type Error: Error + Send + 'static

The error type for state lookups.

Required Methods§

Source

fn account_details( &self, address: &Address, ) -> impl Future<Output = Result<AcctInfo, Self::Error>> + Send

Get account details for an address.

Provided Methods§

Source

fn nonce( &self, address: &Address, ) -> impl Future<Output = Result<u64, Self::Error>> + Send

Get the nonce for an address. Returns the NEXT EXPECTED nonce, i.e. 0 for an address that has never sent a transaction, 1 for an address that has sent exactly one transaction, etc.

Source

fn balance( &self, address: &Address, ) -> impl Future<Output = Result<U256, Self::Error>> + Send

Get the balance for an address.

Source

fn map<T: Send, F: FnOnce(&AcctInfo) -> T + Send>( &self, address: &Address, f: F, ) -> impl Future<Output = Result<T, Self::Error>> + Send

Run an arbitrary check on the account details for an address.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§