Skip to main content

ContextStorage

Trait ContextStorage 

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

Source

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.

Source

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.

Source

fn get_all(&self) -> Result<Vec<ContextEntry>>

Return every stored entry.

§Errors

Returns an error if the underlying storage read fails.

Source

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.

Source

fn clear(&self) -> Result<usize>

Remove all entries. Returns the number of entries removed.

§Errors

Returns an error if the underlying storage delete fails.

Source

fn clear_scope(&self, scope: &str) -> Result<usize>

Remove all entries within a given scope. Returns the number of entries removed.

§Errors

Returns an error if the underlying storage delete fails.

Source

fn count(&self) -> Result<usize>

Return the total number of stored entries.

§Errors

Returns an error if the underlying storage read fails.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§