Store

Trait Store 

Source
pub trait Store: Async + Clone {
    type Error: Debug;

    // Required methods
    fn set(
        &mut self,
        path: Path,
        value: Vec<u8>,
    ) -> Result<Option<Vec<u8>>, Self::Error>;
    fn get(&self, height: Height, path: &Path) -> Option<Vec<u8>>;
    fn delete(&mut self, path: &Path);
    fn commit(&mut self) -> Result<Vec<u8>, Self::Error>;
    fn current_height(&self) -> RawHeight;
    fn get_keys(&self, key_prefix: &Path) -> Vec<Path>;

    // Provided methods
    fn apply(&mut self) -> Result<(), Self::Error> { ... }
    fn reset(&mut self) { ... }
    fn prune(&mut self, height: RawHeight) -> Result<RawHeight, Self::Error> { ... }
}
Expand description

Store trait - maybe provableStore or privateStore

Required Associated Types§

Source

type Error: Debug

Error type - expected to envelope all possible errors in store

Required Methods§

Source

fn set( &mut self, path: Path, value: Vec<u8>, ) -> Result<Option<Vec<u8>>, Self::Error>

Set value for path

Source

fn get(&self, height: Height, path: &Path) -> Option<Vec<u8>>

Get associated value for path at specified height

Source

fn delete(&mut self, path: &Path)

Delete specified path

Source

fn commit(&mut self) -> Result<Vec<u8>, Self::Error>

Commit Pending block to canonical chain and create new Pending

Source

fn current_height(&self) -> RawHeight

Return the current height of the chain

Source

fn get_keys(&self, key_prefix: &Path) -> Vec<Path>

Return all keys that start with specified prefix

Provided Methods§

Source

fn apply(&mut self) -> Result<(), Self::Error>

Apply accumulated changes to Pending

Source

fn reset(&mut self)

Reset accumulated changes

Source

fn prune(&mut self, height: RawHeight) -> Result<RawHeight, Self::Error>

Prune historic blocks upto specified height

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§

Source§

impl Store for InMemoryStore

Source§

impl<S> Store for GrowingStore<S>
where S: Store,

Source§

type Error = <S as Store>::Error

Source§

impl<S> Store for RevertibleStore<S>
where S: Store,

Source§

type Error = <S as Store>::Error

Source§

impl<S> Store for SharedStore<S>
where S: Store,

Source§

type Error = <S as Store>::Error