Skip to main content

WalReader

Struct WalReader 

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

Streaming reader used by recovery. Stops at the first torn record (REC_LEN == 0) or CRC mismatch, returning the cleanly-committed prefix.

Implementations§

Source§

impl WalReader

Source

pub fn open(path: impl AsRef<Path>) -> Result<Self>

Source

pub fn open_with_cipher( path: impl AsRef<Path>, cipher: Option<Box<dyn Cipher>>, ) -> Result<Self>

Open a WAL segment for reading, optionally with a decryption cipher.

Source

pub fn next_record(&mut self) -> Result<Option<Record>>

Read the next record. Returns Ok(None) at a clean end-of-records (zero-length marker or EOF), and Err(TornWrite) for a partial record.

Source

pub fn replay(&mut self) -> Result<Vec<Record>>

Replay all cleanly-committed records. A torn tail (crash mid-append or a partially-flushed last frame) is treated as end-of-log and truncated — the valid prefix is returned. A CRC failure or short read that is followed by a well-formed frame is treated as interior corruption and surfaces as MongrelError::CorruptWal (spec §8.4, review fix #22).

Source

pub fn current_offset(&self) -> u64

Position the write cursor at end of file (for a reopen-and-append path, to be implemented alongside segment rotation).

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.