pub trait StorageData: Sized {
// Required methods
fn backup(&self, _name: &str) -> Result<(), DbError>;
fn copy(&self, name: &str) -> Result<Self, DbError>;
fn len(&self) -> u64;
fn name(&self) -> &str;
fn new(name: &str) -> Result<Self, DbError>;
fn read(
&self,
pos: u64,
value_len: u64,
) -> Result<StorageSlice<'_>, DbError>;
fn rename(&mut self, new_name: &str) -> Result<(), DbError>;
fn resize(&mut self, new_len: u64) -> Result<(), DbError>;
fn write(&mut self, pos: u64, bytes: &[u8]) -> Result<(), DbError>;
// Provided methods
fn flush(&mut self) -> Result<(), DbError> { ... }
fn is_empty(&self) -> bool { ... }
}
Expand description
Minimum set of data operations required by the database to store & retrieve data.
Required Methods§
Sourcefn backup(&self, _name: &str) -> Result<(), DbError>
fn backup(&self, _name: &str) -> Result<(), DbError>
Copy the underlying data storage to a new name
. The
default implementation does nothing. File implementations
might need to copy the underlying file(s).
Sourcefn new(name: &str) -> Result<Self, DbError>
fn new(name: &str) -> Result<Self, DbError>
Constructs or loads the storage name
. The name
might be
a file name or other identifier.
Sourcefn read(&self, pos: u64, value_len: u64) -> Result<StorageSlice<'_>, DbError>
fn read(&self, pos: u64, value_len: u64) -> Result<StorageSlice<'_>, DbError>
Reads value_len
bytes starting at pos
. Returns StorageSlice
(COW).
Sourcefn rename(&mut self, new_name: &str) -> Result<(), DbError>
fn rename(&mut self, new_name: &str) -> Result<(), DbError>
Changes the name of the storage changing also the names of the files (if the storage is file based).
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.