StorageEngine

Trait StorageEngine 

Source
pub trait StorageEngine: Send + Sync {
    // Required methods
    fn put<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 mut self,
        key: &'life1 [u8],
        value: &'life2 [u8],
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn get<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 [u8],
    ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn delete<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        key: &'life1 [u8],
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn scan<'life0, 'life1, 'async_trait>(
        &'life0 self,
        prefix: &'life1 [u8],
    ) -> Pin<Box<dyn Future<Output = Result<Vec<(Vec<u8>, Vec<u8>)>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

A trait for pluggable storage engines. This defines the basic key-value interface that the database core uses.

Required Methods§

Source

fn put<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, key: &'life1 [u8], value: &'life2 [u8], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Puts a key-value pair into the store.

Source

fn get<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Gets a value from the store by its key.

Source

fn delete<'life0, 'life1, 'async_trait>( &'life0 mut self, key: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Deletes a key-value pair from the store.

Source

fn scan<'life0, 'life1, 'async_trait>( &'life0 self, prefix: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = Result<Vec<(Vec<u8>, Vec<u8>)>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Scans a range of keys with a given prefix.

Implementations§

Source§

impl dyn StorageEngine

Source

pub async fn put_block(&mut self, block: &Block) -> Result<Cid>

Stores a content-addressed block in the database. Returns the CID of the stored block.

Source

pub async fn get_block(&self, cid: &Cid) -> Result<Option<Block>>

Retrieves a content-addressed block from the database by its CID.

Implementors§