Skip to main content

WalWriter

Struct WalWriter 

Source
pub struct WalWriter { /* private fields */ }
Expand description

Appends records to a WAL segment and controls the fsync durability policy.

LSNs are assigned by the caller (the engine owns the global counter); the writer only frames, appends, and syncs.

Implementations§

Source§

impl WalWriter

Source

pub fn create(path: &Path, base_lsn: Lsn) -> Result<Self>

Create a new WAL segment file and write its header. Fails if the file already exists.

Source

pub fn open_append(path: &Path) -> Result<Self>

Open an existing WAL segment for appending, validating its header. New records are written at the end of the file.

Source

pub fn append(&mut self, codec: &dyn PageCodec, entry: &WalEntry) -> Result<()>

Frame and append a record, sealing its bytes with codec first (so an encrypting codec leaves no plaintext in the log). Does not fsync; the record is durable only after a subsequent WalWriter::sync.

Source

pub fn sync(&mut self) -> Result<()>

Flush and fsync the segment, making every appended record durable.

Source

pub fn append_sync( &mut self, codec: &dyn PageCodec, entry: &WalEntry, ) -> Result<()>

Append a record and immediately fsync — strict per-commit durability.

Trait Implementations§

Source§

impl Debug for WalWriter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.