Skip to main content

AsyncStore

Trait AsyncStore 

Source
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§

Source

type Error: Error + 'static

Error type for storage operations.

Required Methods§

Source

async fn get(&self, key: &[u8]) -> Result<Option<Vec<u8>>, Self::Error>

Get value by key.

Source

async fn put(&self, key: &[u8], value: &[u8]) -> Result<(), Self::Error>

Store key-value pair.

Source

async fn delete(&self, key: &[u8]) -> Result<(), Self::Error>

Delete key.

Source

async fn batch(&self, ops: &[BatchOp<'_>]) -> Result<(), Self::Error>

Batch write operations.

Provided Methods§

Source

async fn get_shared(&self, key: &[u8]) -> Result<Option<Arc<[u8]>>, Self::Error>

Async immutable shared-byte read.

Source

async fn batch_get_shared_ordered_unique( &self, keys: &[&[u8]], ) -> Result<Vec<Option<Arc<[u8]>>>, Self::Error>

Async ordered retained-byte batch read for unique keys.

Source

fn has_native_shared_reads(&self) -> bool

Whether async shared reads retain backend-owned immutable allocations.

Source

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.

Source

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.

Source

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.

Source

fn prefers_batch_reads(&self) -> bool

Whether this store has an efficient native batched-read implementation.

Source

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.

Source

async fn batch_put(&self, entries: &[(&[u8], &[u8])]) -> Result<(), Self::Error>

Store multiple key-value pairs.

Source

fn supports_hints(&self) -> bool

Whether this store persists performance hints.

Source

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.

Source

async fn get_hint( &self, namespace: &[u8], key: &[u8], ) -> Result<Option<Vec<u8>>, Self::Error>

Retrieve an optional performance hint.

Source

async fn put_hint( &self, namespace: &[u8], key: &[u8], value: &[u8], ) -> Result<(), Self::Error>

Persist an optional performance hint.

Source

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.

Source

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".

Implementations on Foreign Types§

Source§

impl<T: AsyncStore> AsyncStore for Arc<T>

Source§

type Error = <T as AsyncStore>::Error

Source§

async fn get(&self, key: &[u8]) -> Result<Option<Vec<u8>>, Self::Error>

Source§

async fn get_shared(&self, key: &[u8]) -> Result<Option<Arc<[u8]>>, Self::Error>

Source§

async fn batch_get_shared_ordered_unique( &self, keys: &[&[u8]], ) -> Result<Vec<Option<Arc<[u8]>>>, Self::Error>

Source§

fn has_native_shared_reads(&self) -> bool

Source§

async fn put(&self, key: &[u8], value: &[u8]) -> Result<(), Self::Error>

Source§

async fn delete(&self, key: &[u8]) -> Result<(), Self::Error>

Source§

async fn batch(&self, ops: &[BatchOp<'_>]) -> Result<(), Self::Error>

Source§

async fn batch_get( &self, keys: &[&[u8]], ) -> Result<HashMap<Vec<u8>, Vec<u8>>, Self::Error>

Source§

async fn batch_get_ordered( &self, keys: &[&[u8]], ) -> Result<Vec<Option<Vec<u8>>>, Self::Error>

Source§

async fn batch_get_ordered_unique( &self, keys: &[&[u8]], ) -> Result<Vec<Option<Vec<u8>>>, Self::Error>

Source§

fn prefers_batch_reads(&self) -> bool

Source§

fn read_parallelism(&self) -> usize

Source§

async fn batch_put(&self, entries: &[(&[u8], &[u8])]) -> Result<(), Self::Error>

Source§

fn supports_hints(&self) -> bool

Source§

fn prefers_rightmost_path_hints(&self) -> bool

Source§

async fn get_hint( &self, namespace: &[u8], key: &[u8], ) -> Result<Option<Vec<u8>>, Self::Error>

Source§

async fn put_hint( &self, namespace: &[u8], key: &[u8], value: &[u8], ) -> Result<(), Self::Error>

Source§

async fn batch_put_with_hint( &self, entries: &[(&[u8], &[u8])], namespace: &[u8], key: &[u8], value: &[u8], ) -> Result<(), Self::Error>

Source§

async fn publish_nodes( &self, publication: NodePublication<'_>, ) -> Result<(), Self::Error>

Implementors§