pub trait StorageBackend:
'static
+ Debug
+ Send
+ Sync {
// Required methods
fn len(&self) -> Result<u64, Error>;
fn read(&self, offset: u64, out: &mut [u8]) -> Result<(), Error>;
fn set_len(&self, len: u64) -> Result<(), Error>;
fn sync_data(&self) -> Result<(), Error>;
fn write(&self, offset: u64, data: &[u8]) -> Result<(), Error>;
// Provided method
fn close(&self) -> Result<(), Error> { ... }
}
Expand description
Implements persistent storage for a database.
Required Methods§
Sourcefn read(&self, offset: u64, out: &mut [u8]) -> Result<(), Error>
fn read(&self, offset: u64, out: &mut [u8]) -> Result<(), Error>
Reads the specified array of bytes from the storage.
If out.len()
+ offset
exceeds the length of the storage an appropriate Error
must be returned.