pub struct MockMemory { /* private fields */ }Expand description
In-memory mock that stores messages per session.
Each session gets its own Vec<Message>, ensuring test
isolation when multiple sessions are used concurrently.
§Example
use traitclaw_test_utils::memory::MockMemory;
use traitclaw_core::types::message::Message;
use traitclaw_core::Memory;
let mem = MockMemory::new();
mem.append("s1", Message::user("hi")).await.unwrap();
let msgs = mem.messages("s1").await.unwrap();
assert_eq!(msgs.len(), 1);Implementations§
Source§impl MockMemory
impl MockMemory
Trait Implementations§
Source§impl Default for MockMemory
impl Default for MockMemory
Source§impl Memory for MockMemory
impl Memory for MockMemory
Source§fn messages<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<Message>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn messages<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<Message>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get conversation messages for a session.
Source§fn append<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
message: Message,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn append<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
message: Message,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Append a message to the conversation history.
Source§fn get_context<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_session_id: &'life1 str,
_key: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get_context<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_session_id: &'life1 str,
_key: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Get a value from working memory.
Source§fn set_context<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_session_id: &'life1 str,
_key: &'life2 str,
_value: Value,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn set_context<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_session_id: &'life1 str,
_key: &'life2 str,
_value: Value,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Set a value in working memory.
Source§fn recall<'life0, 'life1, 'async_trait>(
&'life0 self,
_query: &'life1 str,
_limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<MemoryEntry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn recall<'life0, 'life1, 'async_trait>(
&'life0 self,
_query: &'life1 str,
_limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<MemoryEntry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Search for relevant memories.
Source§fn store<'life0, 'async_trait>(
&'life0 self,
_entry: MemoryEntry,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn store<'life0, 'async_trait>(
&'life0 self,
_entry: MemoryEntry,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Store a new memory entry.
Source§fn create_session<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn create_session<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Create a new session and return its ID. Read more
Source§fn list_sessions<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn list_sessions<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
List all known session IDs. Read more
Source§fn delete_session<'life0, 'life1, 'async_trait>(
&'life0 self,
_session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn delete_session<'life0, 'life1, 'async_trait>(
&'life0 self,
_session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Delete a session and all associated conversation history and working memory. Read more
Auto Trait Implementations§
impl !Freeze for MockMemory
impl !RefUnwindSafe for MockMemory
impl Send for MockMemory
impl Sync for MockMemory
impl Unpin for MockMemory
impl UnsafeUnpin for MockMemory
impl !UnwindSafe for MockMemory
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