pub trait ContextStorage: Send + Sync {
// Required methods
fn save(&self, entry: &ContextEntry) -> Result<()>;
fn get_top_k(&self, k: usize) -> Result<Vec<ContextEntry>>;
fn get_all(&self) -> Result<Vec<ContextEntry>>;
fn delete(&self, id: &str) -> Result<bool>;
fn clear(&self) -> Result<usize>;
fn clear_scope(&self, scope: &str) -> Result<usize>;
fn count(&self) -> Result<usize>;
}Expand description
Trait for persisting and retrieving context entries.
Implementations must be thread-safe (Send + Sync) to support
concurrent access from multiple worker threads.
Required Methods§
Sourcefn save(&self, entry: &ContextEntry) -> Result<()>
fn save(&self, entry: &ContextEntry) -> Result<()>
Persist a single entry.
§Security
Implementations persist entry.content verbatim — secret scrubbing
happens only in ContextForge::save.
Callers writing through this trait directly are responsible for
scrubbing first (see scrub_secrets).
§Errors
Returns an error if the underlying storage write fails.
Sourcefn get_top_k(&self, k: usize) -> Result<Vec<ContextEntry>>
fn get_top_k(&self, k: usize) -> Result<Vec<ContextEntry>>
Return the top-k entries (most recent or highest priority).
§Errors
Returns an error if the underlying storage read fails.
Sourcefn get_all(&self) -> Result<Vec<ContextEntry>>
fn get_all(&self) -> Result<Vec<ContextEntry>>
Sourcefn delete(&self, id: &str) -> Result<bool>
fn delete(&self, id: &str) -> Result<bool>
Delete an entry by id. Returns true if an entry was removed.
§Errors
Returns an error if the underlying storage delete fails.
Sourcefn clear(&self) -> Result<usize>
fn clear(&self) -> Result<usize>
Remove all entries. Returns the number of entries removed.
§Errors
Returns an error if the underlying storage delete fails.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".