pub struct InMemoryStore<E: Episode> { /* private fields */ }Expand description
Append-only in-memory episode store with deterministic lexical retrieval.
E is the caller’s episode payload; only Episode::summary is
inspected during retrieval.
Implementations§
Source§impl<E: Episode> InMemoryStore<E>
impl<E: Episode> InMemoryStore<E>
Sourcepub fn new() -> Arc<Self>
pub fn new() -> Arc<Self>
Create a fresh store wrapped in Arc for cheap cloning across
agent tasks.
Sourcepub async fn append(&self, episode: E) -> Result<String, PolicyError>
pub async fn append(&self, episode: E) -> Result<String, PolicyError>
Append a new episode and return its storage key.
Keys are stable across the lifetime of the store and follow the
ep-{:016x} template so they sort lexicographically by insertion
order. If the process appends more than u64::MAX episodes, the
key counter saturates and subsequent appends reuse the terminal key.
Sourcepub async fn retrieve_similar(
&self,
query: &str,
k: usize,
) -> Result<Vec<InMemoryHit<E>>, PolicyError>
pub async fn retrieve_similar( &self, query: &str, k: usize, ) -> Result<Vec<InMemoryHit<E>>, PolicyError>
Return up to k episodes most similar to query, sorted by
descending lexical score. Hits with score 0.0 are skipped.
Sourcepub async fn get(&self, key: &str) -> Result<E, PolicyError>
pub async fn get(&self, key: &str) -> Result<E, PolicyError>
Direct lookup by storage key.
Sourcepub async fn len(&self) -> Result<usize, PolicyError>
pub async fn len(&self) -> Result<usize, PolicyError>
Number of episodes currently stored.
Sourcepub async fn is_empty(&self) -> Result<bool, PolicyError>
pub async fn is_empty(&self) -> Result<bool, PolicyError>
Whether the store is empty.
Trait Implementations§
Auto Trait Implementations§
impl<E> !Freeze for InMemoryStore<E>
impl<E> RefUnwindSafe for InMemoryStore<E>
impl<E> Send for InMemoryStore<E>
impl<E> Sync for InMemoryStore<E>
impl<E> Unpin for InMemoryStore<E>where
E: Unpin,
impl<E> UnsafeUnpin for InMemoryStore<E>
impl<E> UnwindSafe for InMemoryStore<E>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more