pub struct LogFile { /* private fields */ }
Expand description
A write-ahead-log.
Implementations§
Source§impl LogFile
impl LogFile
Sourcepub fn first_entry<'l>(&'l mut self) -> Result<LogEntry<'l>, LogError>
pub fn first_entry<'l>(&'l mut self) -> Result<LogEntry<'l>, LogError>
The first entry in the log
Sourcepub fn seek<'l>(&'l mut self, to_index: u64) -> Result<LogEntry<'l>, LogError>
pub fn seek<'l>(&'l mut self, to_index: u64) -> Result<LogEntry<'l>, LogError>
Seek to the given entry in the log
Sourcepub fn first_index(&self) -> u64
pub fn first_index(&self) -> u64
Returns the index/sequence number of the first entry in the log
Sourcepub fn last_index(&self) -> u64
pub fn last_index(&self) -> u64
Returns the index/sequence number of the last entry in the log
Sourcepub fn iter<'s, R: RangeBounds<u64>>(
&'s mut self,
range: R,
) -> Result<LogIterator<'s>, LogError>
pub fn iter<'s, R: RangeBounds<u64>>( &'s mut self, range: R, ) -> Result<LogIterator<'s>, LogError>
Iterate through the log
Sourcepub fn write<R: AsMut<[u8]>>(&mut self, entry: &mut R) -> Result<()>
pub fn write<R: AsMut<[u8]>>(&mut self, entry: &mut R) -> Result<()>
Write the given log entry to the end of the log
Sourcepub fn open<P: AsRef<Path>>(path: P) -> Result<LogFile, LogError>
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
Sourcepub fn compact(&mut self, new_start_index: u64) -> Result<(), LogError>
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.
Auto Trait Implementations§
impl Freeze for LogFile
impl RefUnwindSafe for LogFile
impl Send for LogFile
impl Sync for LogFile
impl Unpin for LogFile
impl UnwindSafe for LogFile
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