pub trait IndexBackend: Send + Sync {
// Required methods
fn put(&self, key: &str, value: &[u8]) -> Result<(), IndexError>;
fn get(&self, key: &str) -> Result<Option<Vec<u8>>, IndexError>;
fn delete(&self, key: &str) -> Result<(), IndexError>;
fn batch_put(
&self,
entries: Vec<(String, Vec<u8>)>,
) -> Result<(), IndexError>;
fn scan(
&self,
visitor: &mut dyn FnMut(&[u8]) -> Result<(), IndexError>,
) -> Result<(), IndexError>;
// Provided method
fn flush(&self) -> Result<(), IndexError> { ... }
}Expand description
Trait for a key-value storage backend for the index. This allows for different storage implementations (e.g., in-memory, Redb).
Required Methods§
Sourcefn put(&self, key: &str, value: &[u8]) -> Result<(), IndexError>
fn put(&self, key: &str, value: &[u8]) -> Result<(), IndexError>
Insert or update a key-value pair.
Sourcefn batch_put(&self, entries: Vec<(String, Vec<u8>)>) -> Result<(), IndexError>
fn batch_put(&self, entries: Vec<(String, Vec<u8>)>) -> Result<(), IndexError>
Insert or update multiple key-value pairs in a batch.
Sourcefn scan(
&self,
visitor: &mut dyn FnMut(&[u8]) -> Result<(), IndexError>,
) -> Result<(), IndexError>
fn scan( &self, visitor: &mut dyn FnMut(&[u8]) -> Result<(), IndexError>, ) -> Result<(), IndexError>
Scan all values in the backend, calling the visitor for each one.
Provided Methods§
Sourcefn flush(&self) -> Result<(), IndexError>
fn flush(&self) -> Result<(), IndexError>
Flush any buffered writes to the backend.