pub struct Wal { /* private fields */ }Expand description
Write-ahead log for buffering document operations between commits.
Appends records to a .luci.wal file. Records are self-delimiting with
per-record xxHash checksums, allowing replay to detect and discard
truncated or corrupted trailing records after a crash.
See [[architecture-storage-format#Write-Ahead Log (WAL)]].
Implementations§
Source§impl Wal
impl Wal
Sourcepub fn open(path: impl AsRef<Path>, mode: DurabilityMode) -> Result<Self>
pub fn open(path: impl AsRef<Path>, mode: DurabilityMode) -> Result<Self>
Open (or create) a WAL file for appending.
New records are appended to the end. If the file already contains
records from a previous session (crash recovery), they remain intact
until truncate is called.
Sourcepub fn append(&mut self, record: &WalRecord) -> Result<()>
pub fn append(&mut self, record: &WalRecord) -> Result<()>
Append a record to the WAL.
In Full durability mode, the write is fsynced before returning. In
Batch and None modes, the record is buffered and only fsynced on
an explicit call to sync.
Sourcepub fn sync(&mut self) -> Result<()>
pub fn sync(&mut self) -> Result<()>
Flush the buffer and fsync the WAL file.
Called by the commit path (in Batch mode) to ensure all appended
records are durable before proceeding with the atomic commit.
Sourcepub fn truncate(&mut self) -> Result<()>
pub fn truncate(&mut self) -> Result<()>
Truncate the WAL to zero bytes.
Called after a successful commit to discard all buffered records (they
are now persisted in the main .luci file as a committed segment).
Sourcepub fn mode(&self) -> DurabilityMode
pub fn mode(&self) -> DurabilityMode
The current durability mode.
Auto Trait Implementations§
impl Freeze for Wal
impl RefUnwindSafe for Wal
impl Send for Wal
impl Sync for Wal
impl Unpin for Wal
impl UnsafeUnpin for Wal
impl UnwindSafe for Wal
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more