Skip to main content

StorageBackend

Trait StorageBackend 

Source
pub trait StorageBackend: Send + Sync {
Show 22 methods // Required methods fn create_memory( &self, input: CreateMemoryInput, ) -> Result<Memory, EngramError>; fn get_memory(&self, id: MemoryId) -> Result<Option<Memory>, EngramError>; fn update_memory( &self, id: MemoryId, input: UpdateMemoryInput, ) -> Result<Memory, EngramError>; fn delete_memory(&self, id: MemoryId) -> Result<(), EngramError>; fn create_memories_batch( &self, inputs: Vec<CreateMemoryInput>, ) -> Result<BatchCreateResult, EngramError>; fn delete_memories_batch( &self, ids: Vec<MemoryId>, ) -> Result<BatchDeleteResult, EngramError>; fn list_memories( &self, options: ListOptions, ) -> Result<Vec<Memory>, EngramError>; fn count_memories(&self, options: ListOptions) -> Result<i64, EngramError>; fn search_memories( &self, query: &str, options: SearchOptions, ) -> Result<Vec<SearchResult>, EngramError>; fn create_crossref( &self, from_id: MemoryId, to_id: MemoryId, edge_type: EdgeType, score: f32, ) -> Result<CrossReference, EngramError>; fn get_crossrefs( &self, memory_id: MemoryId, ) -> Result<Vec<CrossReference>, EngramError>; fn delete_crossref( &self, from_id: MemoryId, to_id: MemoryId, ) -> Result<(), EngramError>; fn list_tags(&self) -> Result<Vec<(String, i64)>, EngramError>; fn get_memories_by_tag( &self, tag: &str, limit: Option<usize>, ) -> Result<Vec<Memory>, EngramError>; fn list_workspaces(&self) -> Result<Vec<(String, i64)>, EngramError>; fn get_workspace_stats( &self, workspace: &str, ) -> Result<HashMap<String, i64>, EngramError>; fn move_to_workspace( &self, ids: Vec<MemoryId>, workspace: &str, ) -> Result<usize, EngramError>; fn get_stats(&self) -> Result<StorageStats, EngramError>; fn health_check(&self) -> Result<HealthStatus, EngramError>; fn optimize(&self) -> Result<(), EngramError>; fn backend_name(&self) -> &'static str; fn schema_version(&self) -> Result<i32, EngramError>;
}
Expand description

Core storage backend trait for Engram (ENG-14)

This trait defines the interface for all storage operations, allowing for multiple backend implementations (SQLite, Turso, Meilisearch).

Required Methods§

Source

fn create_memory(&self, input: CreateMemoryInput) -> Result<Memory, EngramError>

Create a new memory

Source

fn get_memory(&self, id: MemoryId) -> Result<Option<Memory>, EngramError>

Get a memory by ID

Source

fn update_memory( &self, id: MemoryId, input: UpdateMemoryInput, ) -> Result<Memory, EngramError>

Update a memory

Source

fn delete_memory(&self, id: MemoryId) -> Result<(), EngramError>

Delete a memory (soft delete)

Source

fn create_memories_batch( &self, inputs: Vec<CreateMemoryInput>, ) -> Result<BatchCreateResult, EngramError>

Create multiple memories in a single transaction

Source

fn delete_memories_batch( &self, ids: Vec<MemoryId>, ) -> Result<BatchDeleteResult, EngramError>

Delete multiple memories in a single transaction

Source

fn list_memories( &self, options: ListOptions, ) -> Result<Vec<Memory>, EngramError>

List memories with filters

Source

fn count_memories(&self, options: ListOptions) -> Result<i64, EngramError>

Count memories matching filters

Source

fn search_memories( &self, query: &str, options: SearchOptions, ) -> Result<Vec<SearchResult>, EngramError>

Search memories using hybrid search

Source

fn create_crossref( &self, from_id: MemoryId, to_id: MemoryId, edge_type: EdgeType, score: f32, ) -> Result<CrossReference, EngramError>

Create a cross-reference between memories

Source

fn get_crossrefs( &self, memory_id: MemoryId, ) -> Result<Vec<CrossReference>, EngramError>

Get cross-references for a memory

Source

fn delete_crossref( &self, from_id: MemoryId, to_id: MemoryId, ) -> Result<(), EngramError>

Delete a cross-reference

Source

fn list_tags(&self) -> Result<Vec<(String, i64)>, EngramError>

List all tags with usage counts

Source

fn get_memories_by_tag( &self, tag: &str, limit: Option<usize>, ) -> Result<Vec<Memory>, EngramError>

Get memories with a specific tag

Source

fn list_workspaces(&self) -> Result<Vec<(String, i64)>, EngramError>

List all workspaces with memory counts

Source

fn get_workspace_stats( &self, workspace: &str, ) -> Result<HashMap<String, i64>, EngramError>

Get detailed statistics for a workspace

Source

fn move_to_workspace( &self, ids: Vec<MemoryId>, workspace: &str, ) -> Result<usize, EngramError>

Move memories to a different workspace

Source

fn get_stats(&self) -> Result<StorageStats, EngramError>

Get storage statistics

Source

fn health_check(&self) -> Result<HealthStatus, EngramError>

Check storage health

Source

fn optimize(&self) -> Result<(), EngramError>

Run optimization (e.g., VACUUM)

Source

fn backend_name(&self) -> &'static str

Get backend name identifier

Source

fn schema_version(&self) -> Result<i32, EngramError>

Get current schema version

Implementors§