LogFile

Struct LogFile 

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

A write-ahead-log.

Implementations§

Source§

impl LogFile

Source

pub fn first_entry<'l>(&'l mut self) -> Result<LogEntry<'l>, LogError>

The first entry in the log

Source

pub fn seek<'l>(&'l mut self, to_index: u64) -> Result<LogEntry<'l>, LogError>

Seek to the given entry in the log

Source

pub fn first_index(&self) -> u64

Returns the index/sequence number of the first entry in the log

Source

pub fn last_index(&self) -> u64

Returns the index/sequence number of the last entry in the log

Source

pub fn iter<'s, R: RangeBounds<u64>>( &'s mut self, range: R, ) -> Result<LogIterator<'s>, LogError>

Iterate through the log

Source

pub fn write<R: AsMut<[u8]>>(&mut self, entry: &mut R) -> Result<()>

Write the given log entry to the end of the log

Source

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

Flush writes to disk

Source

pub fn open<P: AsRef<Path>>(path: P) -> Result<LogFile, LogError>

Open the log. Takes out an advisory lock.

This is O(n): we have to iterate to the end of the log in order to clean interrupted writes and determine the length of the log

Source

pub fn compact(&mut self, new_start_index: u64) -> Result<(), LogError>

Compact the log, removing entries older than new_start_index.

This is done by copying all entries >= new_start_index to a temporary file, than overriding the old log file once the copy is complete.

Before compacting, the log is flushed.

Source

pub fn restart(&mut self, starting_index: u64) -> Result<(), LogError>

Clear all entries in the write-ahead-log and restart at the given index.

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V