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§
Sourcefn load_all(&self) -> Vec<DurableMemory>
fn load_all(&self) -> Vec<DurableMemory>
Every memory, most recently seen first.
Sourcefn search(&self, query: &str) -> Vec<DurableMemory>
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.
Sourcefn persist_batch(
&self,
memories: Vec<DurableMemory>,
) -> Result<usize, MemoryError>
fn persist_batch( &self, memories: Vec<DurableMemory>, ) -> Result<usize, MemoryError>
Write these, returning how many landed.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".