pub struct FileStorage { /* private fields */ }Expand description
File-backed Storage holding an advisory lock on its database.
Implementations§
Source§impl FileStorage
impl FileStorage
Sourcepub fn open(
base: impl Into<PathBuf>,
fsync: FsyncPolicy,
) -> Result<Self, HostError>
pub fn open( base: impl Into<PathBuf>, fsync: FsyncPolicy, ) -> Result<Self, HostError>
Opens (creating as needed) the database at base and takes the
exclusive writer lock — one writer at a time. Readers do not take
this lock (they pin a generation file via
[pin_current_generation] instead), so a writer and any number of
readers coexist across threads or processes (the versioned
MVCC layout).
§Errors
HostError::Locked when another writer owns the lock;
HostError::Io for filesystem failures.
Sourcepub fn journal_bytes(&self) -> u64
pub fn journal_bytes(&self) -> u64
Current journal size in bytes (drives the snapshot policy).
Trait Implementations§
Source§impl Debug for FileStorage
impl Debug for FileStorage
Source§impl Storage for FileStorage
impl Storage for FileStorage
Source§fn read_snapshot(&mut self) -> Result<Option<Vec<u8>>, HostError>
fn read_snapshot(&mut self) -> Result<Option<Vec<u8>>, HostError>
The full snapshot image, or
None when no database exists yet
(first run).Source§fn write_snapshot(&mut self, bytes: &[u8]) -> Result<(), HostError>
fn write_snapshot(&mut self, bytes: &[u8]) -> Result<(), HostError>
Atomically replaces the snapshot image.
Source§fn read_journal(&mut self) -> Result<Vec<u8>, HostError>
fn read_journal(&mut self) -> Result<Vec<u8>, HostError>
All journal bytes accumulated since the last snapshot (empty is
normal).
Source§fn append_journal(&mut self, entry: &[u8]) -> Result<(), HostError>
fn append_journal(&mut self, entry: &[u8]) -> Result<(), HostError>
Appends one framed journal entry (see
crate::journal).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