Skip to main content

MemoryStore

Struct MemoryStore 

Source
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

Source

pub fn new() -> Self

Create a new empty in-memory store.

Trait Implementations§

Source§

impl Default for MemoryStore

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

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,

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,

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,

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,

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,

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> StateReader for T
where 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,

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,

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,

Semantic search within a scope.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.