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§
Required Methods§
Sourcefn create_test_operations(
count: usize,
seed: u64,
starting_loc: u64,
) -> Vec<Self::Operation>
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.
Sourcefn add_operations(
&mut self,
operations: Vec<Self::Operation>,
) -> impl Future<Output = Result<(), Error<Self::Family>>> + Send
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.
Sourcefn current_floor(&self) -> u64
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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".