pub trait Mutable: Contiguous + Sized {
// Required methods
fn append(
self,
item: &Self::Item,
) -> impl Future<Output = Result<(Self, u64), Error>> + Send;
fn append_many(
self,
items: Many<'_, Self::Item>,
) -> impl Future<Output = Result<(Self, u64), Error>> + Send;
fn prune(
self,
min_position: u64,
) -> impl Future<Output = Result<(Self, bool), Error>> + Send;
fn start_sync(
self,
) -> impl Future<Output = Result<(Self, Handle<()>), Error>> + Send;
fn commit(self) -> impl Future<Output = Result<Self, Error>> + Send;
fn sync(self) -> impl Future<Output = Result<Self, Error>> + Send;
fn destroy(self) -> impl Future<Output = Result<(), Error>> + Send;
}Expand description
A Contiguous journal that supports appending and prefix pruning.
Required Methods§
Sourcefn append(
self,
item: &Self::Item,
) -> impl Future<Output = Result<(Self, u64), Error>> + Send
fn append( self, item: &Self::Item, ) -> impl Future<Output = Result<(Self, u64), Error>> + Send
Append a new item to the journal, returning its position.
Positions are consecutively increasing starting from 0. The position of each item is stable across pruning (i.e., if item X has position 5, it will always have position 5 even if earlier items are pruned).
§Errors
Returns an error if the underlying storage operation fails or if the item cannot be encoded.
Sourcefn append_many(
self,
items: Many<'_, Self::Item>,
) -> impl Future<Output = Result<(Self, u64), Error>> + Send
fn append_many( self, items: Many<'_, Self::Item>, ) -> impl Future<Output = Result<(Self, u64), Error>> + Send
Append items to the journal, returning the position of the last item appended.
Returns Error::EmptyAppend if items is empty.
Sourcefn prune(
self,
min_position: u64,
) -> impl Future<Output = Result<(Self, bool), Error>> + Send
fn prune( self, min_position: u64, ) -> impl Future<Output = Result<(Self, bool), Error>> + Send
Prune items at positions strictly less than min_position.
Returns true if any data was pruned, false otherwise.
§Behavior
- If
min_position > bounds.end, the prune is capped tobounds.end(no error is returned) - Some items with positions less than
min_positionmay be retained due to section/blob alignment - This operation is not atomic, but implementations guarantee the journal is left in a recoverable state if a crash occurs during pruning
§Errors
Returns an error if the underlying storage operation fails.
Sourcefn start_sync(
self,
) -> impl Future<Output = Result<(Self, Handle<()>), Error>> + Send
fn start_sync( self, ) -> impl Future<Output = Result<(Self, Handle<()>), Error>> + Send
Begin durably persisting the current state of the journal.
Awaiting the returned Handle provides the same durability guarantee as Self::commit for the state present when the call begins (later appends need their own sync). Also tries to advance the recovery watermark to the previous proven durable size, bounding startup recovery. Use Self::sync to guarantee no recovery is needed. Dropping the handle does not cancel the sync or lose its failure, which resurfaces at latest on the next Self::sync.
Sourcefn commit(self) -> impl Future<Output = Result<Self, Error>> + Send
fn commit(self) -> impl Future<Output = Result<Self, Error>> + Send
Durably persist the journal, guaranteeing the current state will survive a crash.
For a stronger guarantee that eliminates potential recovery, use Self::sync instead.
Sourcefn sync(self) -> impl Future<Output = Result<Self, Error>> + Send
fn sync(self) -> impl Future<Output = Result<Self, Error>> + Send
Durably persist the journal, guaranteeing the current state will survive a crash, and that no recovery will be needed on startup.
This provides a stronger guarantee than Self::commit but may be slower.
Sourcefn destroy(self) -> impl Future<Output = Result<(), Error>> + Send
fn destroy(self) -> impl Future<Output = Result<(), Error>> + Send
Destroy the journal, removing all associated storage.
This method consumes the journal and deletes all persisted data, leaving behind no storage artifacts. This can be used to clean up disk resources in tests.
§Crash Safety
This operation is intended for final teardown and is not crash-safe. If interrupted, reopening the same storage may observe partially removed state. Use a reset operation provided by the concrete type when the journal must remain recoverable.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".