Trait redb::StorageBackend

source ·
pub trait StorageBackend: 'static + Debug + Send + Sync {
    // Required methods
    fn len(&self) -> Result<u64, Error>;
    fn read(&self, offset: u64, len: usize) -> Result<Vec<u8>, Error>;
    fn set_len(&self, len: u64) -> Result<(), Error>;
    fn sync_data(&self, eventual: bool) -> Result<(), Error>;
    fn write(&self, offset: u64, data: &[u8]) -> Result<(), Error>;
}
Expand description

Implements persistent storage for a database.

Required Methods§

source

fn len(&self) -> Result<u64, Error>

Gets the current length of the storage.

source

fn read(&self, offset: u64, len: usize) -> Result<Vec<u8>, Error>

Reads the specified array of bytes from the storage.

If len + offset exceeds the length of the storage an appropriate Error should be returned or a panic may occur.

source

fn set_len(&self, len: u64) -> Result<(), Error>

Sets the length of the storage.

When extending the storage the new positions should be zero initialized.

source

fn sync_data(&self, eventual: bool) -> Result<(), Error>

Syncs all buffered data with the persistent storage.

If eventual is true, data may become persistent at some point after this call returns, but the storage must gaurantee that a write barrier is inserted: i.e. all writes before this call to sync_data() will become persistent before any writes that occur after.

source

fn write(&self, offset: u64, data: &[u8]) -> Result<(), Error>

Writes the specified array to the storage.

Implementors§