[][src]Trait store::Store

pub trait Store: Sync + Send + Sized {
    fn get_bytes(
        &self,
        column: &str,
        key: &[u8]
    ) -> Result<Option<Vec<u8>>, Error>;
fn put_bytes(
        &self,
        column: &str,
        key: &[u8],
        value: &[u8]
    ) -> Result<(), Error>;
fn key_exists(&self, column: &str, key: &[u8]) -> Result<bool, Error>;
fn key_delete(&self, column: &str, key: &[u8]) -> Result<(), Error>; fn put(&self, key: &Hash256, item: &impl StoreItem) -> Result<(), Error> { ... }
fn get<I: StoreItem>(&self, key: &Hash256) -> Result<Option<I>, Error> { ... }
fn exists<I: StoreItem>(&self, key: &Hash256) -> Result<bool, Error> { ... }
fn delete<I: StoreItem>(&self, key: &Hash256) -> Result<(), Error> { ... }
fn get_block_at_preceeding_slot<E: EthSpec>(
        &self,
        start_block_root: Hash256,
        slot: Slot
    ) -> Result<Option<(Hash256, BeaconBlock<E>)>, Error> { ... } }

An object capable of storing and retrieving objects implementing StoreItem.

A Store is fundamentally backed by a key-value database, however it provides support for columns. A simple column implementation might involve prefixing a key with some bytes unique to each column.

Required methods

fn get_bytes(&self, column: &str, key: &[u8]) -> Result<Option<Vec<u8>>, Error>

Retrieve some bytes in column with key.

fn put_bytes(&self, column: &str, key: &[u8], value: &[u8]) -> Result<(), Error>

Store some value in column, indexed with key.

fn key_exists(&self, column: &str, key: &[u8]) -> Result<bool, Error>

Return true if key exists in column.

fn key_delete(&self, column: &str, key: &[u8]) -> Result<(), Error>

Removes key from column.

Loading content...

Provided methods

fn put(&self, key: &Hash256, item: &impl StoreItem) -> Result<(), Error>

Store an item in Self.

fn get<I: StoreItem>(&self, key: &Hash256) -> Result<Option<I>, Error>

Retrieve an item from Self.

fn exists<I: StoreItem>(&self, key: &Hash256) -> Result<bool, Error>

Returns true if the given key represents an item in Self.

fn delete<I: StoreItem>(&self, key: &Hash256) -> Result<(), Error>

Remove an item from Self.

fn get_block_at_preceeding_slot<E: EthSpec>(
    &self,
    start_block_root: Hash256,
    slot: Slot
) -> Result<Option<(Hash256, BeaconBlock<E>)>, Error>

Given the root of an existing block in the store (start_block_root), return a parent block with the specified slot.

Returns None if no parent block exists at that slot, or if slot is greater than the slot of start_block_root.

Loading content...

Implementors

impl Store for LevelDB[src]

fn get_bytes(&self, col: &str, key: &[u8]) -> Result<Option<Vec<u8>>, Error>[src]

Retrieve some bytes in column with key.

fn put_bytes(&self, col: &str, key: &[u8], val: &[u8]) -> Result<(), Error>[src]

Store some value in column, indexed with key.

fn key_exists(&self, col: &str, key: &[u8]) -> Result<bool, Error>[src]

Return true if key exists in column.

fn key_delete(&self, col: &str, key: &[u8]) -> Result<(), Error>[src]

Removes key from column.

impl Store for MemoryStore[src]

fn get_bytes(&self, col: &str, key: &[u8]) -> Result<Option<Vec<u8>>, Error>[src]

Get the value of some key from the database. Returns None if the key does not exist.

fn put_bytes(&self, col: &str, key: &[u8], val: &[u8]) -> Result<(), Error>[src]

Puts a key in the database.

fn key_exists(&self, col: &str, key: &[u8]) -> Result<bool, Error>[src]

Return true if some key exists in some column.

fn key_delete(&self, col: &str, key: &[u8]) -> Result<(), Error>[src]

Delete some key from the database.

Loading content...