pub trait AsyncStore {
type Error: Error + 'static;
Show 19 methods
// Required methods
async fn get(&self, key: &[u8]) -> Result<Option<Vec<u8>>, Self::Error>;
async fn put(&self, key: &[u8], value: &[u8]) -> Result<(), Self::Error>;
async fn delete(&self, key: &[u8]) -> Result<(), Self::Error>;
async fn batch(&self, ops: &[BatchOp<'_>]) -> Result<(), Self::Error>;
// Provided methods
async fn get_shared(
&self,
key: &[u8],
) -> Result<Option<Arc<[u8]>>, Self::Error> { ... }
async fn batch_get_shared_ordered_unique(
&self,
keys: &[&[u8]],
) -> Result<Vec<Option<Arc<[u8]>>>, Self::Error> { ... }
fn has_native_shared_reads(&self) -> bool { ... }
async fn batch_get(
&self,
keys: &[&[u8]],
) -> Result<HashMap<Vec<u8>, Vec<u8>>, Self::Error> { ... }
async fn batch_get_ordered(
&self,
keys: &[&[u8]],
) -> Result<Vec<Option<Vec<u8>>>, Self::Error> { ... }
async fn batch_get_ordered_unique(
&self,
keys: &[&[u8]],
) -> Result<Vec<Option<Vec<u8>>>, Self::Error> { ... }
fn prefers_batch_reads(&self) -> bool { ... }
fn read_parallelism(&self) -> usize { ... }
async fn batch_put(
&self,
entries: &[(&[u8], &[u8])],
) -> Result<(), Self::Error> { ... }
fn supports_hints(&self) -> bool { ... }
fn prefers_rightmost_path_hints(&self) -> bool { ... }
async fn get_hint(
&self,
namespace: &[u8],
key: &[u8],
) -> Result<Option<Vec<u8>>, Self::Error> { ... }
async fn put_hint(
&self,
namespace: &[u8],
key: &[u8],
value: &[u8],
) -> Result<(), Self::Error> { ... }
async fn batch_put_with_hint(
&self,
entries: &[(&[u8], &[u8])],
namespace: &[u8],
key: &[u8],
value: &[u8],
) -> Result<(), Self::Error> { ... }
fn publish_nodes<'a>(
&'a self,
publication: NodePublication<'a>,
) -> impl Future<Output = Result<(), Self::Error>> + 'a { ... }
}Expand description
Async storage backend trait for Prolly Trees.
This trait mirrors Store for remote, browser, object-store, and
background-agent workloads. It is part of the runtime-neutral core and
intentionally does not require a Tokio dependency.
The base trait does not require Send or Sync so single-threaded browser
stores can implement it. Async managers or native backends may add stronger
bounds when they need cross-thread execution.
Required Associated Types§
Required Methods§
Provided Methods§
Async immutable shared-byte read.
Async ordered retained-byte batch read for unique keys.
Whether async shared reads retain backend-owned immutable allocations.
Sourceasync fn batch_get(
&self,
keys: &[&[u8]],
) -> Result<HashMap<Vec<u8>, Vec<u8>>, Self::Error>
async fn batch_get( &self, keys: &[&[u8]], ) -> Result<HashMap<Vec<u8>, Vec<u8>>, Self::Error>
Retrieve multiple keys as a map.
The default implementation uses AsyncStore::batch_get_ordered and
returns only found keys.
Sourceasync fn batch_get_ordered(
&self,
keys: &[&[u8]],
) -> Result<Vec<Option<Vec<u8>>>, Self::Error>
async fn batch_get_ordered( &self, keys: &[&[u8]], ) -> Result<Vec<Option<Vec<u8>>>, Self::Error>
Retrieve multiple keys while preserving request order.
The default implementation deduplicates repeated keys, performs point
reads, and expands results back to the original request order. If
AsyncStore::read_parallelism is greater than one, point reads are
overlapped up to that limit.
Sourceasync fn batch_get_ordered_unique(
&self,
keys: &[&[u8]],
) -> Result<Vec<Option<Vec<u8>>>, Self::Error>
async fn batch_get_ordered_unique( &self, keys: &[&[u8]], ) -> Result<Vec<Option<Vec<u8>>>, Self::Error>
Retrieve unique keys in request order.
Callers use this when they have already deduplicated keys. The default
implementation avoids duplicate planning and still respects
AsyncStore::read_parallelism.
Sourcefn prefers_batch_reads(&self) -> bool
fn prefers_batch_reads(&self) -> bool
Whether this store has an efficient native batched-read implementation.
Sourcefn read_parallelism(&self) -> usize
fn read_parallelism(&self) -> usize
Maximum in-flight point reads for default ordered batch reads.
Stores with true native multi-get should override
AsyncStore::batch_get_ordered directly. Stores that only have async
point reads can return a value greater than one here to overlap fetches.
Sourceasync fn batch_put(&self, entries: &[(&[u8], &[u8])]) -> Result<(), Self::Error>
async fn batch_put(&self, entries: &[(&[u8], &[u8])]) -> Result<(), Self::Error>
Store multiple key-value pairs.
Sourcefn supports_hints(&self) -> bool
fn supports_hints(&self) -> bool
Whether this store persists performance hints.
Sourcefn prefers_rightmost_path_hints(&self) -> bool
fn prefers_rightmost_path_hints(&self) -> bool
Whether append-heavy writes should maintain the engine’s rightmost-path hint.
This is a measured performance preference, not a correctness capability. Stores should opt in only when they also support hints and path hydration saves more work than persisting one hint for each appended tree root.
Sourceasync fn get_hint(
&self,
namespace: &[u8],
key: &[u8],
) -> Result<Option<Vec<u8>>, Self::Error>
async fn get_hint( &self, namespace: &[u8], key: &[u8], ) -> Result<Option<Vec<u8>>, Self::Error>
Retrieve an optional performance hint.
Sourceasync fn put_hint(
&self,
namespace: &[u8],
key: &[u8],
value: &[u8],
) -> Result<(), Self::Error>
async fn put_hint( &self, namespace: &[u8], key: &[u8], value: &[u8], ) -> Result<(), Self::Error>
Persist an optional performance hint.
Sourceasync fn batch_put_with_hint(
&self,
entries: &[(&[u8], &[u8])],
namespace: &[u8],
key: &[u8],
value: &[u8],
) -> Result<(), Self::Error>
async fn batch_put_with_hint( &self, entries: &[(&[u8], &[u8])], namespace: &[u8], key: &[u8], value: &[u8], ) -> Result<(), Self::Error>
Store content-addressed nodes and one hint atomically when supported.
Sourcefn publish_nodes<'a>(
&'a self,
publication: NodePublication<'a>,
) -> impl Future<Output = Result<(), Self::Error>> + 'a
fn publish_nodes<'a>( &'a self, publication: NodePublication<'a>, ) -> impl Future<Output = Result<(), Self::Error>> + 'a
Publish canonical immutable nodes with advisory logical context.
The default preserves existing async batch and optional-hint behavior. Store overrides may optimize by origin only when all general-path guarantees remain unchanged.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".