Skip to main content

StateReader

Trait StateReader 

Source
pub trait StateReader: Send + Sync {
    // Required methods
    fn contains(&self, address: &str) -> Result<bool, StateDatabaseError>;
    fn get(&self, address: &str) -> Result<Option<Vec<u8>>, StateDatabaseError>;
    fn leaves(
        &self,
        prefix: Option<&str>,
    ) -> Result<Box<StateIter>, StateDatabaseError>;
}

Required Methods§

Source

fn contains(&self, address: &str) -> Result<bool, StateDatabaseError>

Returns true if the given address exists in State; false, otherwise.

Will return a StateDatabaseError if any errors occur while querying for the existence of the given address.

Source

fn get(&self, address: &str) -> Result<Option<Vec<u8>>, StateDatabaseError>

Returns the data for a given address, if it exists. In the case where the address exists, but has no data, it will return None.

Will return an StateDatabaseError::NotFound, if the given address is not in State.

Source

fn leaves( &self, prefix: Option<&str>, ) -> Result<Box<StateIter>, StateDatabaseError>

A state value is considered a leaf if it has data stored at the address.

Returns an iterator over address-value pairs in state.

Returns Err if the prefix is invalid, or if any other database errors occur while creating the iterator.

Trait Implementations§

Source§

impl From<Box<dyn StateReader>> for IdentityView

Source§

fn from(state_reader: Box<dyn StateReader>) -> Self

Converts to this type from the input type.
Source§

impl From<Box<dyn StateReader>> for SettingsView

Source§

fn from(state_reader: Box<dyn StateReader>) -> Self

Converts to this type from the input type.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§