pub struct MemoryStore { /* private fields */ }Expand description
In-memory state store backed by a HashMap behind a RwLock.
Suitable for testing, prototyping, and single-process use cases where persistence across restarts is not required.
Create an unbounded store with MemoryStore::new or a capacity-limited
LRU store with MemoryStore::bounded.
Implementations§
Source§impl MemoryStore
impl MemoryStore
Sourcepub fn bounded(capacity: usize) -> Self
pub fn bounded(capacity: usize) -> Self
Create a bounded in-memory store that evicts least-recently-used entries
when the entry count exceeds capacity.
Reads and writes both count as “use” for LRU ordering.
Pinned scope entries (written via write_hinted with Lifetime::Durable)
are never evicted.
Trait Implementations§
Source§impl Default for MemoryStore
impl Default for MemoryStore
Source§impl StateStore for MemoryStore
impl StateStore for MemoryStore
Source§fn read<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
scope: &'life1 Scope,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>, StateError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn read<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
scope: &'life1 Scope,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>, StateError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Read a value by key within a scope.
Returns None if the key doesn’t exist.
Source§fn write<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
scope: &'life1 Scope,
key: &'life2 str,
value: Value,
) -> Pin<Box<dyn Future<Output = Result<(), StateError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn write<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
scope: &'life1 Scope,
key: &'life2 str,
value: Value,
) -> Pin<Box<dyn Future<Output = Result<(), StateError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Write a value. Creates or overwrites.
Source§fn delete<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
scope: &'life1 Scope,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), StateError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn delete<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
scope: &'life1 Scope,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), StateError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Delete a value. No-op if key doesn’t exist.
Source§fn list<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
scope: &'life1 Scope,
prefix: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, StateError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn list<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
scope: &'life1 Scope,
prefix: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, StateError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
List keys under a prefix within a scope.
Source§fn search<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
scope: &'life1 Scope,
query: &'life2 str,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, StateError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn search<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
scope: &'life1 Scope,
query: &'life2 str,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, StateError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Semantic search within a scope. Returns matching keys
with relevance scores. Implementations that don’t support
search return an empty vec (not an error).
Source§fn write_hinted<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
scope: &'life1 Scope,
key: &'life2 str,
value: Value,
options: &'life3 StoreOptions,
) -> Pin<Box<dyn Future<Output = Result<(), StateError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn write_hinted<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
scope: &'life1 Scope,
key: &'life2 str,
value: Value,
options: &'life3 StoreOptions,
) -> Pin<Box<dyn Future<Output = Result<(), StateError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Write a value with advisory options. Backends may ignore options. Read more
Source§fn clear_transient(&self)
fn clear_transient(&self)
Clear all transient-lifetime entries from the store. Read more
Source§fn read_hinted<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
scope: &'life1 Scope,
key: &'life2 str,
_options: &'life3 StoreOptions,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>, StateError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
fn read_hinted<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
scope: &'life1 Scope,
key: &'life2 str,
_options: &'life3 StoreOptions,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>, StateError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
Read a value with advisory options. Backends may ignore options. Read more
Source§fn link<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_scope: &'life1 Scope,
_link: &'life2 MemoryLink,
) -> Pin<Box<dyn Future<Output = Result<(), StateError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn link<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_scope: &'life1 Scope,
_link: &'life2 MemoryLink,
) -> Pin<Box<dyn Future<Output = Result<(), StateError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Create a link between two memory entries. Read more
Source§fn unlink<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
_scope: &'life1 Scope,
_from_key: &'life2 str,
_to_key: &'life3 str,
_relation: &'life4 str,
) -> Pin<Box<dyn Future<Output = Result<(), StateError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Self: 'async_trait,
fn unlink<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
_scope: &'life1 Scope,
_from_key: &'life2 str,
_to_key: &'life3 str,
_relation: &'life4 str,
) -> Pin<Box<dyn Future<Output = Result<(), StateError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Self: 'async_trait,
Remove a link between two memory entries. Read more
Source§fn traverse<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_scope: &'life1 Scope,
_from_key: &'life2 str,
_relation: Option<&'life3 str>,
_max_depth: u32,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, StateError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
fn traverse<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_scope: &'life1 Scope,
_from_key: &'life2 str,
_relation: Option<&'life3 str>,
_max_depth: u32,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, StateError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
Traverse links from a starting key. Read more
Source§fn search_hinted<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
scope: &'life1 Scope,
query: &'life2 str,
limit: usize,
_options: &'life3 SearchOptions,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, StateError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
fn search_hinted<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
scope: &'life1 Scope,
query: &'life2 str,
limit: usize,
_options: &'life3 SearchOptions,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, StateError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait,
Enhanced search with advisory options. Read more
Auto Trait Implementations§
impl !Freeze for MemoryStore
impl !RefUnwindSafe for MemoryStore
impl Send for MemoryStore
impl Sync for MemoryStore
impl Unpin for MemoryStore
impl UnsafeUnpin for MemoryStore
impl UnwindSafe for MemoryStore
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> StateReader for Twhere
T: StateStore,
impl<T> StateReader for Twhere
T: StateStore,
Source§fn read<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
scope: &'life1 Scope,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>, StateError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
T: 'async_trait,
fn read<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
scope: &'life1 Scope,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>, StateError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
T: 'async_trait,
Read a value by key within a scope.
Source§fn list<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
scope: &'life1 Scope,
prefix: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, StateError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
T: 'async_trait,
fn list<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
scope: &'life1 Scope,
prefix: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, StateError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
T: 'async_trait,
List keys under a prefix within a scope.
Source§fn search<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
scope: &'life1 Scope,
query: &'life2 str,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, StateError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
T: 'async_trait,
fn search<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
scope: &'life1 Scope,
query: &'life2 str,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, StateError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
T: 'async_trait,
Semantic search within a scope.
Source§fn read_hinted<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
scope: &'life1 Scope,
key: &'life2 str,
options: &'life3 StoreOptions,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>, StateError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
T: 'async_trait,
fn read_hinted<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
scope: &'life1 Scope,
key: &'life2 str,
options: &'life3 StoreOptions,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>, StateError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
T: 'async_trait,
Read a value with advisory options. Default: ignores options.
Source§fn clear_transient(&self)
fn clear_transient(&self)
Clear all transient-lifetime entries. Default: no-op. Read more
Source§fn traverse<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
scope: &'life1 Scope,
from_key: &'life2 str,
relation: Option<&'life3 str>,
max_depth: u32,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, StateError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
T: 'async_trait,
fn traverse<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
scope: &'life1 Scope,
from_key: &'life2 str,
relation: Option<&'life3 str>,
max_depth: u32,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, StateError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
T: 'async_trait,
Traverse links from a starting key. Read more
Source§fn search_hinted<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
scope: &'life1 Scope,
query: &'life2 str,
limit: usize,
options: &'life3 SearchOptions,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, StateError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
T: 'async_trait,
fn search_hinted<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
scope: &'life1 Scope,
query: &'life2 str,
limit: usize,
options: &'life3 SearchOptions,
) -> Pin<Box<dyn Future<Output = Result<Vec<SearchResult>, StateError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
T: 'async_trait,
Enhanced search with advisory options. Read more