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.
Failures are reported as io::Error, which is std::io::Error whenever std is available.
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.
Provided Methods§
Sourcefn close(&self) -> Result<(), Error>
fn close(&self) -> Result<(), Error>
Release any resources held by the backend
Note: redb will not access the backend after calling this method and will call it exactly
once: when the Database is dropped, or, if a WriteTransaction was live at that
point, when that transaction completes, or if opening the database fails
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".