Skip to main content

ExampleDatabase

Trait ExampleDatabase 

Source
pub trait ExampleDatabase: Sized {
    type Family: Family;
    type Operation: Encode + Send + Sync + 'static;

    // Required methods
    fn create_test_operations(
        count: usize,
        seed: u64,
        starting_loc: u64,
    ) -> Vec<Self::Operation>;
    fn add_operations(
        &mut self,
        operations: Vec<Self::Operation>,
    ) -> impl Future<Output = Result<(), Error<Self::Family>>> + Send;
    fn current_floor(&self) -> u64;
    fn root(&self) -> Key;
    fn name() -> &'static str;
}
Expand description

Common surface shared by all database adapters used by the sync example binaries.

This is intentionally the smallest shared interface: enough to create test data, mutate the database during the demo, and log the resulting root. More specific sync capabilities live in Syncable and CompactSyncable.

Required Associated Types§

Source

type Family: Family

The merkle family used by this database.

Source

type Operation: Encode + Send + Sync + 'static

The type of operations in the database.

Required Methods§

Source

fn create_test_operations( count: usize, seed: u64, starting_loc: u64, ) -> Vec<Self::Operation>

Create test operations with the given count and seed.

starting_loc is the floor each commit in the returned stream should carry. Callers applying the stream to a fresh db pass 0; callers growing an already-running db pass the current value of Self::current_floor so floors stay monotonic across appends. The returned operations must end with a commit operation.

Source

fn add_operations( &mut self, operations: Vec<Self::Operation>, ) -> impl Future<Output = Result<(), Error<Self::Family>>> + Send

Add operations to the database, ignoring any input that doesn’t end with a commit operation.

Source

fn current_floor(&self) -> u64

Return the floor anchor a caller should pass as starting_loc when generating a stream to append to this db’s current state.

Source

fn root(&self) -> Key

Get the database’s root digest.

Source

fn name() -> &'static str

Get the display name used in logs.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<E> ExampleDatabase for commonware_sync::databases::any::Database<E>
where E: Storage + Clock + Metrics,

Source§

impl<E> ExampleDatabase for commonware_sync::databases::current::Database<E>
where E: Storage + Clock + Metrics,

Source§

impl<E> ExampleDatabase for commonware_sync::databases::immutable::Database<E>
where E: Storage + Clock + Metrics,

Source§

impl<E> ExampleDatabase for commonware_sync::databases::immutable_compact::Database<E>
where E: Storage + Clock + Metrics,

Source§

impl<E> ExampleDatabase for commonware_sync::databases::keyless::Database<E>
where E: Storage + Clock + Metrics,

Source§

impl<E> ExampleDatabase for commonware_sync::databases::keyless_compact::Database<E>
where E: Storage + Clock + Metrics,