pub trait Backend: Send + Sync {
// Required methods
fn put_row(
&self,
table: &str,
key: &[u8],
row: &VectorRow,
) -> Result<(), StoreError>;
fn get_row(
&self,
table: &str,
key: &[u8],
) -> Result<Option<VectorRow>, StoreError>;
fn delete_row(&self, table: &str, key: &[u8]) -> Result<bool, StoreError>;
fn for_each_row(
&self,
table: &str,
f: &mut RowVisitor<'_>,
) -> Result<(), StoreError>;
fn put_schema(&self, schema: &TableSchema) -> Result<(), StoreError>;
fn list_schemas(&self) -> Result<Vec<TableSchema>, StoreError>;
}Expand description
Storage backend trait.
Implementations are responsible for persisting / fetching
the row map and the HNSW snapshot. The MVP ships an
in-memory backend (MemoryBackend); a Noxu-backed
backend lives behind the noxu feature.
Required Methods§
Sourcefn put_row(
&self,
table: &str,
key: &[u8],
row: &VectorRow,
) -> Result<(), StoreError>
fn put_row( &self, table: &str, key: &[u8], row: &VectorRow, ) -> Result<(), StoreError>
Persist row under (table, key). Overwrites prior
values.
Sourcefn get_row(
&self,
table: &str,
key: &[u8],
) -> Result<Option<VectorRow>, StoreError>
fn get_row( &self, table: &str, key: &[u8], ) -> Result<Option<VectorRow>, StoreError>
Fetch the row at (table, key). Returns None for a
missing row.
Sourcefn delete_row(&self, table: &str, key: &[u8]) -> Result<bool, StoreError>
fn delete_row(&self, table: &str, key: &[u8]) -> Result<bool, StoreError>
Remove (table, key). Returns true when present,
false when absent.
Sourcefn for_each_row(
&self,
table: &str,
f: &mut RowVisitor<'_>,
) -> Result<(), StoreError>
fn for_each_row( &self, table: &str, f: &mut RowVisitor<'_>, ) -> Result<(), StoreError>
Iterate every (key, row) in table in unspecified
order. Used to rebuild the HNSW index on startup.
Sourcefn put_schema(&self, schema: &TableSchema) -> Result<(), StoreError>
fn put_schema(&self, schema: &TableSchema) -> Result<(), StoreError>
Persist a TableSchema.
Sourcefn list_schemas(&self) -> Result<Vec<TableSchema>, StoreError>
fn list_schemas(&self) -> Result<Vec<TableSchema>, StoreError>
List every persisted TableSchema.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".