pub trait StorageBackend: Send + Sync {
// Required methods
fn get(&self, key: &[u8]) -> Result<Option<Vec<u8>>>;
fn insert(&self, key: &[u8], value: &[u8]) -> Result<()>;
fn remove(&self, key: &[u8]) -> Result<()>;
fn prefix_scan(&self, prefix: &[u8]) -> Result<Vec<(Vec<u8>, Vec<u8>)>>;
fn prefix_count(&self, prefix: &[u8]) -> Result<usize>;
fn prefix_scan_keys(&self, prefix: &[u8]) -> Result<Vec<Vec<u8>>>;
fn prefix_scan_batch(
&self,
prefix: &[u8],
batch_size: usize,
after_key: Option<&[u8]>,
) -> Result<Vec<(Vec<u8>, Vec<u8>)>>;
fn range_scan(
&self,
start: &[u8],
end: &[u8],
) -> Result<Vec<(Vec<u8>, Vec<u8>)>>;
fn batch(&self) -> Box<dyn BatchOperations>;
fn flush(&self) -> Result<()>;
}Expand description
Storage backend trait for key-value operations.
Required Methods§
Sourcefn prefix_count(&self, prefix: &[u8]) -> Result<usize>
fn prefix_count(&self, prefix: &[u8]) -> Result<usize>
Counts entries matching the given prefix without materializing values.
§Errors
Returns an error if the storage operation fails.
Sourcefn prefix_scan_keys(&self, prefix: &[u8]) -> Result<Vec<Vec<u8>>>
fn prefix_scan_keys(&self, prefix: &[u8]) -> Result<Vec<Vec<u8>>>
Returns only keys matching the given prefix, without loading values.
§Errors
Returns an error if the storage operation fails.
Sourcefn prefix_scan_batch(
&self,
prefix: &[u8],
batch_size: usize,
after_key: Option<&[u8]>,
) -> Result<Vec<(Vec<u8>, Vec<u8>)>>
fn prefix_scan_batch( &self, prefix: &[u8], batch_size: usize, after_key: Option<&[u8]>, ) -> Result<Vec<(Vec<u8>, Vec<u8>)>>
Scans entries matching prefix in batches, starting after after_key.
Returns at most batch_size entries. Pass None for after_key to start
from the beginning of the prefix range.
§Errors
Returns an error if the storage operation fails.
Sourcefn batch(&self) -> Box<dyn BatchOperations>
fn batch(&self) -> Box<dyn BatchOperations>
Creates a new batch for atomic operations.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".