pub struct CommitLog { /* private fields */ }
Expand description
The commit log is an append-only sequence of messages.
Implementations§
Source§impl CommitLog
impl CommitLog
Sourcepub fn new(opts: LogOptions) -> Result<CommitLog>
pub fn new(opts: LogOptions) -> Result<CommitLog>
Creates or opens an existing commit log.
Sourcepub fn append_msg<B: AsRef<[u8]>>(
&mut self,
payload: B,
) -> Result<Offset, AppendError>
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.
Sourcepub fn append<T>(&mut self, buf: &mut T) -> Result<OffsetRange, AppendError>where
T: MessageSetMut,
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.
Sourcepub fn append_with_offsets<T>(
&mut self,
buf: &T,
) -> Result<OffsetRange, AppendError>where
T: MessageSet,
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.
Sourcepub fn last_offset(&self) -> Option<Offset>
pub fn last_offset(&self) -> Option<Offset>
Gets the last written offset.
Sourcepub fn next_offset(&self) -> Offset
pub fn next_offset(&self) -> Offset
Gets the latest offset
Sourcepub fn read(
&self,
start: Offset,
limit: ReadLimit,
) -> Result<MessageBuf, ReadError>
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.
Sourcepub fn reader<R: LogSliceReader>(
&self,
reader: &mut R,
start: Offset,
limit: ReadLimit,
) -> Result<Option<R::Result>, ReadError>
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.
Auto Trait Implementations§
impl Freeze for CommitLog
impl RefUnwindSafe for CommitLog
impl Send for CommitLog
impl Sync for CommitLog
impl Unpin for CommitLog
impl UnwindSafe for CommitLog
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more