Skip to main content

MemoryStorage

Trait MemoryStorage 

Source
pub trait MemoryStorage: Send + Sync {
    // Required methods
    fn load_all(&self) -> Vec<DurableMemory>;
    fn search(&self, query: &str) -> Vec<DurableMemory>;
    fn persist_batch(
        &self,
        memories: Vec<DurableMemory>,
    ) -> Result<usize, MemoryError>;
    fn remove(&self, name: &str) -> Result<bool, MemoryError>;
}
Expand description

Where durable memories are kept.

Deliberately narrow: the operations the engine performs, not the ones the file-backed implementation happens to expose. A backend that is not a directory should not have to grow a concept of an index file to satisfy this.

Required Methods§

Source

fn load_all(&self) -> Vec<DurableMemory>

Every memory, most recently seen first.

Source

fn search(&self, query: &str) -> Vec<DurableMemory>

Memories matching query, however this backend matches. The shipped implementation is a substring scan; a backend with an index is expected to do better, and nothing depends on the ranking.

Source

fn persist_batch( &self, memories: Vec<DurableMemory>, ) -> Result<usize, MemoryError>

Write these, returning how many landed.

Source

fn remove(&self, name: &str) -> Result<bool, MemoryError>

Forget one by name; false if it was not there.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§