Skip to main content

Storage

Trait Storage 

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

Source

type Entity

The entity type this storage handles

Source

type Document

The document type this storage handles

Source

type Chunk

The chunk type this storage handles

Source

type Error: Error + Send + Sync + 'static

The error type returned by storage operations

Required Methods§

Source

fn store_entity(&mut self, entity: Self::Entity) -> Result<String>

Store an entity and return its assigned ID

Source

fn retrieve_entity(&self, id: &str) -> Result<Option<Self::Entity>>

Retrieve an entity by its ID

Source

fn store_document(&mut self, document: Self::Document) -> Result<String>

Store a document and return its assigned ID

Source

fn retrieve_document(&self, id: &str) -> Result<Option<Self::Document>>

Retrieve a document by its ID

Source

fn store_chunk(&mut self, chunk: Self::Chunk) -> Result<String>

Store a chunk and return its assigned ID

Source

fn retrieve_chunk(&self, id: &str) -> Result<Option<Self::Chunk>>

Retrieve a chunk by its ID

Source

fn list_entities(&self) -> Result<Vec<String>>

List all entity IDs

Source

fn store_entities_batch( &mut self, entities: Vec<Self::Entity>, ) -> Result<Vec<String>>

Batch operations for performance

Implementors§

Source§

impl Storage for MemoryStorage

Available on crate feature async only.