Persistable

Trait Persistable 

Source
pub trait Persistable {
    type Error;

    // Required methods
    fn sync(&mut self) -> impl Future<Output = Result<(), Self::Error>> + Send;
    fn destroy(self) -> impl Future<Output = Result<(), Self::Error>> + Send;

    // Provided method
    fn commit(&mut self) -> impl Future<Output = Result<(), Self::Error>> + Send { ... }
}
Expand description

A storage structure with capabilities to persist and recover state across restarts.

Required Associated Types§

Source

type Error

The error type returned when there is a failure from the underlying storage system.

Required Methods§

Source

fn sync(&mut self) -> impl Future<Output = Result<(), Self::Error>> + Send

Durably persist the structure, 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.

Source

fn destroy(self) -> impl Future<Output = Result<(), Self::Error>> + Send

Destroy the structure, removing all associated storage.

This method consumes the structure and deletes all persisted data, leaving behind no storage artifacts. This can be used to clean up disk resources in tests.

Provided Methods§

Source

fn commit(&mut self) -> impl Future<Output = Result<(), Self::Error>> + Send

Durably persist the structure, guaranteeing the current state will survive a crash.

For a stronger guarantee that eliminates potential recovery, use Self::sync instead.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<E, C, H> Persistable for commonware_storage::journal::authenticated::Journal<E, C, H, Clean<H::Digest>>
where E: Storage + Clock + Metrics, C: Contiguous<Item: EncodeShared> + Persistable<Error = Error>, H: Hasher,

Source§

impl<E, K, V, T> Persistable for commonware_storage::qmdb::store::db::Db<E, K, V, T, Durable>
where E: Storage + Clock + Metrics, K: Array, V: VariableValue, T: Translator,

Source§

impl<E: RStorage + Clock + Metrics, K: Array, V: FixedValue, H: Hasher, T: Translator, const N: usize> Persistable for commonware_storage::qmdb::current::ordered::fixed::Db<E, K, V, H, T, N, Merkleized<H>, Durable>

Source§

impl<E: RStorage + Clock + Metrics, K: Array, V: FixedValue, H: Hasher, T: Translator, const N: usize> Persistable for commonware_storage::qmdb::current::unordered::fixed::Db<E, K, V, H, T, N, Merkleized<H>, Durable>

Source§

impl<E: Storage + Metrics + Clock, K: Array, V: CodecShared> Persistable for Freezer<E, K, V>

Source§

impl<E: Storage + Metrics + Clock, V: CodecFixedShared> Persistable for Ordinal<E, V>

Source§

impl<E: Storage + Metrics, A: CodecFixedShared> Persistable for commonware_storage::journal::contiguous::fixed::Journal<E, A>

Source§

impl<E: Storage + Metrics, V: CodecShared> Persistable for commonware_storage::journal::contiguous::variable::Journal<E, V>