pub trait Archive {
type Key: Array;
type Value: Codec;
// Required methods
fn put(
&mut self,
index: u64,
key: Self::Key,
value: Self::Value,
) -> impl Future<Output = Result<(), Error>>;
fn get(
&self,
identifier: Identifier<'_, Self::Key>,
) -> impl Future<Output = Result<Option<Self::Value>, Error>>;
fn has(
&self,
identifier: Identifier<'_, Self::Key>,
) -> impl Future<Output = Result<bool, Error>>;
fn next_gap(&self, index: u64) -> (Option<u64>, Option<u64>);
fn sync(&mut self) -> impl Future<Output = Result<(), Error>>;
fn close(self) -> impl Future<Output = Result<(), Error>>;
fn destroy(self) -> impl Future<Output = Result<(), Error>>;
// Provided method
fn put_sync(
&mut self,
index: u64,
key: Self::Key,
value: Self::Value,
) -> impl Future<Output = Result<(), Error>> { ... }
}
Expand description
A write-once key-value store where each key is associated with a unique index.
Required Associated Types§
Required Methods§
Sourcefn put(
&mut self,
index: u64,
key: Self::Key,
value: Self::Value,
) -> impl Future<Output = Result<(), Error>>
fn put( &mut self, index: u64, key: Self::Key, value: Self::Value, ) -> impl Future<Output = Result<(), Error>>
Store an item in Archive. Both indices and keys are assumed to both be globally unique.
If the index already exists, put does nothing and returns. If the same key is stored multiple times at different indices (not recommended), any value associated with the key may be returned.
Sourcefn get(
&self,
identifier: Identifier<'_, Self::Key>,
) -> impl Future<Output = Result<Option<Self::Value>, Error>>
fn get( &self, identifier: Identifier<'_, Self::Key>, ) -> impl Future<Output = Result<Option<Self::Value>, Error>>
Retrieve an item from Archive.
Sourcefn has(
&self,
identifier: Identifier<'_, Self::Key>,
) -> impl Future<Output = Result<bool, Error>>
fn has( &self, identifier: Identifier<'_, Self::Key>, ) -> impl Future<Output = Result<bool, Error>>
Check if an item exists in Archive.
Sourcefn next_gap(&self, index: u64) -> (Option<u64>, Option<u64>)
fn next_gap(&self, index: u64) -> (Option<u64>, Option<u64>)
Retrieve the end of the current range including index
(inclusive) and
the start of the next range after index
(if it exists).
This is useful for driving backfill operations over the archive.
Provided Methods§
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.