Struct CommitLog

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

The commit log is an append-only sequence of messages.

Implementations§

Source§

impl CommitLog

Source

pub fn new(opts: LogOptions) -> Result<CommitLog>

Creates or opens an existing commit log.

Source

pub fn append_msg<B: AsRef<[u8]>>( &mut self, payload: B, ) -> Result<Offset, AppendError>

Appends a single message to the log, returning the offset appended.

Source

pub fn append<T>(&mut self, buf: &mut T) -> Result<OffsetRange, AppendError>
where T: MessageSetMut,

Appends log entrites to the commit log, returning the offsets appended.

Source

pub fn append_with_offsets<T>( &mut self, buf: &T, ) -> Result<OffsetRange, AppendError>
where T: MessageSet,

Appends log entrites to the commit log, returning the offsets appended.

The offsets are expected to already be set within the buffer.

Source

pub fn last_offset(&self) -> Option<Offset>

Gets the last written offset.

Source

pub fn next_offset(&self) -> Offset

Gets the latest offset

Source

pub fn read( &self, start: Offset, limit: ReadLimit, ) -> Result<MessageBuf, ReadError>

Reads a portion of the log, starting with the start offset, inclusive, up to the limit.

Source

pub fn reader<R: LogSliceReader>( &self, reader: &mut R, start: Offset, limit: ReadLimit, ) -> Result<Option<R::Result>, ReadError>

Reads a portion of the log, starting with the start offset, inclusive, up to the limit via the reader.

Source

pub fn truncate(&mut self, offset: Offset) -> Result<()>

Truncates a file after the offset supplied. The resulting log will contain entries up to the offset.

Source

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

Forces a flush of the log.

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.