pub struct SyncDiskStorage { /* private fields */ }Expand description
High-durability synchronous disk writer.
Every write is flushed to disk before returning. Zero data loss on crash, but lower throughput than AsyncDiskStorage. Enable with WRITE_MODE=sync.
Implementations§
Trait Implementations§
Source§impl StorageBackend for SyncDiskStorage
impl StorageBackend for SyncDiskStorage
Source§fn write_entry(&self, entry: &LogEntry) -> Result<(), DbError>
fn write_entry(&self, entry: &LogEntry) -> Result<(), DbError>
Serialize entry to JSON, write it to the BufWriter, and flush immediately.
This call blocks until the OS has accepted the data.
Source§fn read_log(&self) -> Result<Vec<LogEntry>, DbError>
fn read_log(&self) -> Result<Vec<LogEntry>, DbError>
Read all entries from the log file into a Vec.
Source§fn compact(&self, entries: Vec<LogEntry>) -> Result<(), DbError>
fn compact(&self, entries: Vec<LogEntry>) -> Result<(), DbError>
Compact the log: write a binary snapshot, swap the log file with an empty one, then reopen the writer.
Source§fn read_at(&self, offset: u64, length: u32) -> Result<Vec<u8>, DbError>
fn read_at(&self, offset: u64, length: u32) -> Result<Vec<u8>, DbError>
Read exactly length bytes from the log at offset.
Source§fn stream_log_into(
&self,
f: &mut dyn FnMut(LogEntry, u32) -> ControlFlow<(), ()>,
) -> Result<u64, DbError>
fn stream_log_into( &self, f: &mut dyn FnMut(LogEntry, u32) -> ControlFlow<(), ()>, ) -> Result<u64, DbError>
Stream log entries into state using snapshot + delta replay. Same logic as AsyncDiskStorage::stream_log_into — see that method for details.
Auto Trait Implementations§
impl Freeze for SyncDiskStorage
impl RefUnwindSafe for SyncDiskStorage
impl Send for SyncDiskStorage
impl Sync for SyncDiskStorage
impl Unpin for SyncDiskStorage
impl UnsafeUnpin for SyncDiskStorage
impl UnwindSafe for SyncDiskStorage
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