pub struct FileStorage { /* private fields */ }Expand description
Single file based storage with write ahead log (WAL) for resiliency
implementing StorageData. It uses the storage name as the file
name (.{name} for WAL). It allows multiple readers from the file
by opening additional temporary file handles if the single member file
handle is being used (read). The StorageData::read() always returns
owning buffer.
The StorageData::backup() is implemented so that it copes the file
to the new name.
The StorageData::flush() merely clears the WAL. This implementation
relies on the OS to flush the content to the disk. It is specifically not
using manual calls to File::sync_data() / File::sync_all() because they
result in extreme slowdown.
Trait Implementations§
Source§impl Debug for FileStorage
impl Debug for FileStorage
Source§impl Drop for FileStorage
impl Drop for FileStorage
Source§impl StorageData for FileStorage
impl StorageData for FileStorage
Source§fn 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).Source§fn flush(&mut self) -> Result<(), DbError>
fn flush(&mut self) -> Result<(), DbError>
Flushes any buffers to the underlying storage (e.g. file). The
default implementation does nothing.
Source§fn 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.Source§fn 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).
Source§fn resize(&mut self, new_len: u64) -> Result<(), DbError>
fn resize(&mut self, new_len: u64) -> Result<(), DbError>
Resizes the underlying storage to
new_len. If the storage is enlarged as
a result the new bytes should be initialized to 0_u8.Auto Trait Implementations§
impl !Freeze for FileStorage
impl RefUnwindSafe for FileStorage
impl Send for FileStorage
impl Sync for FileStorage
impl Unpin for FileStorage
impl UnsafeUnpin for FileStorage
impl UnwindSafe for FileStorage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more