pub struct RotateLog { /* private fields */ }Expand description
Implementations§
Source§impl RotateLog
impl RotateLog
Sourcepub fn append(&mut self, data: impl AsRef<[u8]>) -> Result<()>
pub fn append(&mut self, data: impl AsRef<[u8]>) -> Result<()>
Append data to the writable Log.
Sourcepub fn lookup(
&self,
index_id: usize,
key: impl Into<Bytes>,
) -> Result<RotateLogLookupIter<'_>>
pub fn lookup( &self, index_id: usize, key: impl Into<Bytes>, ) -> Result<RotateLogLookupIter<'_>>
Look up an entry using the given index. The index_id is the index of
index_defs stored in OpenOptions.
Sourcepub fn slice_to_bytes(&self, slice: &[u8]) -> Bytes
pub fn slice_to_bytes(&self, slice: &[u8]) -> Bytes
Convert a slice to Bytes.
Do not copy the slice if it’s from the main on-disk buffer of one of the loaded logs.
Sourcepub fn lookup_latest(
&self,
index_id: usize,
key: impl AsRef<[u8]>,
) -> Result<LogLookupIter<'_>>
pub fn lookup_latest( &self, index_id: usize, key: impl AsRef<[u8]>, ) -> Result<LogLookupIter<'_>>
Look up an entry using the given index. The index_id is the index of
index_defs stored in OpenOptions.
Unlike RotateLog::lookup, this function only checks the “latest”
(i.e. “writable”) Log without checking others. It is useful to make
sure certain contents depending on other entries are inserted into
the same Log.
Practically, a flush_filter should also be used to make sure dependent
entries are stored in a same Log. So this function will panic if
flush_filter is not set on OpenOptions.
Sourcepub fn remove_old_logs(&mut self) -> Result<()>
pub fn remove_old_logs(&mut self) -> Result<()>
Attempt to remove outdated logs.
Does nothing if the content of the ‘latest’ file has changed on disk,
which indicates rotation was triggered elsewhere, or the RotateLog
is in-memory.
Sourcepub fn is_changed_on_disk(&self) -> bool
pub fn is_changed_on_disk(&self) -> bool
Returns true if sync will load more data on disk.
This function is optimized to be called frequently. It does not access the filesystem directly, but communicate using a shared mmap buffer.
This is not about testing buffered pending changes. To access buffered
pending changes, use RotateLog::iter_dirty instead.
Sourcepub fn flush(&mut self) -> Result<u8>
pub fn flush(&mut self) -> Result<u8>
Renamed. Use RotateLog::sync instead.
Sourcepub fn iter(&self) -> impl Iterator<Item = Result<&[u8]>>
pub fn iter(&self) -> impl Iterator<Item = Result<&[u8]>>
Iterate over all the entries.
The entries are returned in FIFO order.
Sourcepub fn iter_dirty(&self) -> impl Iterator<Item = Result<&[u8]>>
pub fn iter_dirty(&self) -> impl Iterator<Item = Result<&[u8]>>
Iterate over all dirty entries.