Skip to main content

StorageRead

Trait StorageRead 

Source
pub trait StorageRead: Send + Sync {
    // Required methods
    fn get<'life0, 'async_trait>(
        &'life0 self,
        key: Bytes,
    ) -> Pin<Box<dyn Future<Output = StorageResult<Option<Record>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn scan_iter<'life0, 'async_trait>(
        &'life0 self,
        range: BytesRange,
    ) -> Pin<Box<dyn Future<Output = StorageResult<Box<dyn StorageIterator + Send + 'static>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn scan<'life0, 'async_trait>(
        &'life0 self,
        range: BytesRange,
    ) -> Pin<Box<dyn Future<Output = StorageResult<Vec<Record>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Common read operations supported by both Storage and StorageSnapshot.

This trait provides the core read methods that are shared between full storage access and point-in-time snapshots. By extracting these common operations, we can write code that works with both storage types.

Required Methods§

Source

fn get<'life0, 'async_trait>( &'life0 self, key: Bytes, ) -> Pin<Box<dyn Future<Output = StorageResult<Option<Record>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Retrieves a single record by exact key.

Returns Ok(None) if the key is not present.

Source

fn scan_iter<'life0, 'async_trait>( &'life0 self, range: BytesRange, ) -> Pin<Box<dyn Future<Output = StorageResult<Box<dyn StorageIterator + Send + 'static>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns an iterator over records in the given range.

The returned iterator is owned and does not borrow from the storage, allowing it to be stored in structs or passed across await points.

Provided Methods§

Source

fn scan<'life0, 'async_trait>( &'life0 self, range: BytesRange, ) -> Pin<Box<dyn Future<Output = StorageResult<Vec<Record>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Collects all records in the range into a Vec.

Implementors§