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.
Implementations§
Source§impl MemoryStore
impl MemoryStore
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).
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.