pub trait Storage {
type Entity;
type Document;
type Chunk;
type Error: Error + Send + Sync + 'static;
// Required methods
fn store_entity(&mut self, entity: Self::Entity) -> Result<String>;
fn retrieve_entity(&self, id: &str) -> Result<Option<Self::Entity>>;
fn store_document(&mut self, document: Self::Document) -> Result<String>;
fn retrieve_document(&self, id: &str) -> Result<Option<Self::Document>>;
fn store_chunk(&mut self, chunk: Self::Chunk) -> Result<String>;
fn retrieve_chunk(&self, id: &str) -> Result<Option<Self::Chunk>>;
fn list_entities(&self) -> Result<Vec<String>>;
fn store_entities_batch(
&mut self,
entities: Vec<Self::Entity>,
) -> Result<Vec<String>>;
}Expand description
Core storage abstraction for persisting and retrieving entities, documents, and graph data
§Synchronous Version
This trait provides synchronous operations for storage.
Required Associated Types§
Required Methods§
Sourcefn store_entity(&mut self, entity: Self::Entity) -> Result<String>
fn store_entity(&mut self, entity: Self::Entity) -> Result<String>
Store an entity and return its assigned ID
Sourcefn retrieve_entity(&self, id: &str) -> Result<Option<Self::Entity>>
fn retrieve_entity(&self, id: &str) -> Result<Option<Self::Entity>>
Retrieve an entity by its ID
Sourcefn store_document(&mut self, document: Self::Document) -> Result<String>
fn store_document(&mut self, document: Self::Document) -> Result<String>
Store a document and return its assigned ID
Sourcefn retrieve_document(&self, id: &str) -> Result<Option<Self::Document>>
fn retrieve_document(&self, id: &str) -> Result<Option<Self::Document>>
Retrieve a document by its ID
Sourcefn store_chunk(&mut self, chunk: Self::Chunk) -> Result<String>
fn store_chunk(&mut self, chunk: Self::Chunk) -> Result<String>
Store a chunk and return its assigned ID
Sourcefn list_entities(&self) -> Result<Vec<String>>
fn list_entities(&self) -> Result<Vec<String>>
List all entity IDs