Skip to main content

LineReader

Struct LineReader 

Source
pub struct LineReader<'index> { /* private fields */ }
Expand description

Reads single lines by seq, holding one segment open across reads.

One handle and one buffer serve the whole stretch, and a walk that goes forward never seeks at all — the position the previous line left is the position the next one wants. A jump from a known position moves relative to it, so a line that already sits in the buffer — the next line of one run, a few lines of other runs further on — is read without a seek or a refill. What this replaces opened the segment again for every line and then read it one byte at a time. Over a fifty-thousand record ledger on one windows-x86_64 NVMe machine (2026-09-02): 734 µs a line then, against 0.89 µs walking forward and 5.82 µs walking backward now.

This held handle is why line reading is the index’s one step outside Vfs (crates/storage/spec/Vfs.lean §8-15): the seam’s read_at opens the segment per call, which is the 734 µs this type exists to avoid. Nothing here writes, so the crash semantics the seam is there to model have nothing to say about it.

Implementations§

Source§

impl LineReader<'_>

Source

pub fn line_at(&mut self, seq: Seq) -> Result<Vec<u8>, StorageError>

One line, without its terminator. A seq absent from the index is a caller error, not a corrupt ledger.

Auto Trait Implementations§

§

impl<'index> Freeze for LineReader<'index>

§

impl<'index> RefUnwindSafe for LineReader<'index>

§

impl<'index> Send for LineReader<'index>

§

impl<'index> Sync for LineReader<'index>

§

impl<'index> Unpin for LineReader<'index>

§

impl<'index> UnsafeUnpin for LineReader<'index>

§

impl<'index> UnwindSafe for LineReader<'index>

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.