pub struct Generic<R: Repo, T> { /* private fields */ }Expand description
A commitlog generic over the storage backend as well as the type of records
its Commits contain.
Implementations§
Source§impl<R: Repo, T> Generic<R, T>
impl<R: Repo, T> Generic<R, T>
pub fn open(repo: R, opts: Options) -> Result<Self>
Sourcepub fn epoch(&self) -> u64
pub fn epoch(&self) -> u64
Get the current epoch.
See also: Commit::epoch.
Sourcepub fn set_epoch(&mut self, epoch: u64) -> Result<Option<Committed>>
pub fn set_epoch(&mut self, epoch: u64) -> Result<Option<Committed>>
Update the current epoch.
Calls Self::commit to flush all data of the previous epoch, and
returns the result.
Does nothing if the given epoch is equal to the current epoch.
§Errors
If epoch is smaller than the current epoch, an error of kind
io::ErrorKind::InvalidInput is returned.
Also see Self::commit.
Sourcepub fn commit(&mut self) -> Result<Option<Committed>>
pub fn commit(&mut self) -> Result<Option<Committed>>
Write the currently buffered data to storage and rotate segments as necessary.
Note that this does not imply that the data is durable, in particular
when a filesystem storage backend is used. Call Self::sync to flush
any OS buffers to stable storage.
§Errors
If an error occurs writing the data, the current Commit buffer is
retained, but a new segment is created. Retrying in case of an Err
return value thus will write the current data to that new segment.
If this fails, however, the next attempt to create a new segment will
fail with io::ErrorKind::AlreadyExists. Encountering this error kind
this means that something is seriously wrong underlying storage, and the
caller should stop writing to the log.
Sourcepub fn sync(&mut self)
pub fn sync(&mut self)
Force the currently active segment to be flushed to storage.
Using a filesystem backend, this means to call fsync(2).
§Panics
As an fsync failure leaves a file in a more of less undefined state,
this method panics in this case, thereby preventing any further writes
to the log and forcing the user to re-read the state from disk.
Sourcepub fn max_committed_offset(&self) -> Option<u64>
pub fn max_committed_offset(&self) -> Option<u64>
The last transaction offset written to disk, or None if nothing has
been written yet.
Note that this does not imply durability: Self::sync may not have
been called at this offset.
Sourcepub fn min_committed_offset(&self) -> Option<u64>
pub fn min_committed_offset(&self) -> Option<u64>
The first transaction offset written to disk, or None if nothing has
been written yet.
pub fn commits_from(&self, offset: u64) -> Commits<R> ⓘ
pub fn reset(self) -> Result<Self>
pub fn reset_to(self, offset: u64) -> Result<Self>
Source§impl<R: Repo, T: Encode> Generic<R, T>
impl<R: Repo, T: Encode> Generic<R, T>
Trait Implementations§
Auto Trait Implementations§
impl<R, T> Freeze for Generic<R, T>
impl<R, T> RefUnwindSafe for Generic<R, T>
impl<R, T> Send for Generic<R, T>
impl<R, T> Sync for Generic<R, T>
impl<R, T> Unpin for Generic<R, T>
impl<R, T> UnwindSafe for Generic<R, T>
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more