pub struct InMemoryStore<E>where
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> InMemoryStore<E>where
E: Episode,
impl<E> InMemoryStore<E>where
E: Episode,
Sourcepub fn new() -> Arc<InMemoryStore<E>> ⓘ
pub fn new() -> Arc<InMemoryStore<E>> ⓘ
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§
Source§impl<E> Debug for InMemoryStore<E>
impl<E> Debug for InMemoryStore<E>
Source§impl<E> Default for InMemoryStore<E>where
E: Episode,
impl<E> Default for InMemoryStore<E>where
E: Episode,
Source§fn default() -> InMemoryStore<E>
fn default() -> InMemoryStore<E>
Returns the “default value” for a type. Read more
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more