Struct commitlog::CommitLog
[−]
[src]
pub struct CommitLog { /* fields omitted */ }
The commit log is an append-only sequence of messages.
Methods
impl CommitLog
[src]
fn new(opts: LogOptions) -> Result<CommitLog>
Creates or opens an existing commit log.
fn append_msg<B: AsRef<[u8]>>(
&mut self,
payload: B
) -> Result<Offset, AppendError>
&mut self,
payload: B
) -> Result<Offset, AppendError>
Appends a single message to the log, returning the offset appended.
fn append<T>(&mut self, buf: &mut T) -> Result<OffsetRange, AppendError> where
T: MessageSetMut,
T: MessageSetMut,
Appends log entrites to the commit log, returning the offsets appended.
fn last_offset(&self) -> Option<Offset>
Gets the last written offset.
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.
fn reader<R: LogSliceReader>(
&self,
start: Offset,
limit: ReadLimit
) -> Result<R::Result, ReadError>
&self,
start: Offset,
limit: ReadLimit
) -> Result<R::Result, ReadError>
Reads a portion of the log, starting with the start
offset, inclusive, up to the limit
via the reader.
fn truncate(&mut self, offset: Offset) -> Result<()>
Truncates a file after the offset supplied. The resulting log will contain entries up to the offset.
fn flush(&mut self) -> Result<()>
Forces a flush of the log.