pub struct MemorySessionStore { /* private fields */ }Expand description
In-memory session store for testing, development, and prototyping.
Sessions are stored in HashMap<Uuid, Session> and messages in
HashMap<Uuid, Vec<MessageRecord>>, both protected by RwLock.
A reverse index message_id → session_id enables O(1) message lookups
in update_usage. Data is lost when the
process exits. Implements SessionStore.
Implementations§
Trait Implementations§
Source§impl Default for MemorySessionStore
impl Default for MemorySessionStore
Source§fn default() -> MemorySessionStore
fn default() -> MemorySessionStore
Returns the “default value” for a type. Read more
Source§impl SessionStore for MemorySessionStore
impl SessionStore for MemorySessionStore
Source§fn create_session<'life0, 'async_trait>(
&'life0 self,
session: Session,
) -> Pin<Box<dyn Future<Output = StoreResult<Session>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn create_session<'life0, 'async_trait>(
&'life0 self,
session: Session,
) -> Pin<Box<dyn Future<Output = StoreResult<Session>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Persists a new session and returns it with server-assigned fields.
Source§fn list_sessions<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StoreResult<Vec<Session>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_sessions<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StoreResult<Vec<Session>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Returns all sessions ordered by most recently updated (descending).
Source§fn get_session<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = StoreResult<Option<Session>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_session<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = StoreResult<Option<Session>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Returns a session by identifier, or
None if not found.Source§fn delete_session<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = StoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete_session<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = StoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Deletes a session and all related data (cascading delete). Read more
Source§fn update_session<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
id: &'life1 Uuid,
title: &'life2 str,
model: Option<&'life3 ModelName>,
) -> Pin<Box<dyn Future<Output = StoreResult<Session>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn update_session<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
id: &'life1 Uuid,
title: &'life2 str,
model: Option<&'life3 ModelName>,
) -> Pin<Box<dyn Future<Output = StoreResult<Session>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Updates a session’s title and/or model. Read more
Source§fn append_message<'life0, 'async_trait>(
&'life0 self,
message: MessageRecord,
) -> Pin<Box<dyn Future<Output = StoreResult<MessageRecord>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn append_message<'life0, 'async_trait>(
&'life0 self,
message: MessageRecord,
) -> Pin<Box<dyn Future<Output = StoreResult<MessageRecord>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Appends a message to a session’s history.
Source§fn list_messages<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = StoreResult<Vec<MessageRecord>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list_messages<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = StoreResult<Vec<MessageRecord>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Returns all messages for a session ordered by creation time.
Source§fn update_usage<'life0, 'life1, 'async_trait>(
&'life0 self,
message_id: &'life1 Uuid,
usage: TokenUsage,
) -> Pin<Box<dyn Future<Output = StoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn update_usage<'life0, 'life1, 'async_trait>(
&'life0 self,
message_id: &'life1 Uuid,
usage: TokenUsage,
) -> Pin<Box<dyn Future<Output = StoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Updates token usage on an existing message record.
Source§fn list_sessions_paginated<'life0, 'async_trait>(
&'life0 self,
pagination: Pagination,
filter: SessionFilter,
) -> Pin<Box<dyn Future<Output = StoreResult<Vec<Session>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_sessions_paginated<'life0, 'async_trait>(
&'life0 self,
pagination: Pagination,
filter: SessionFilter,
) -> Pin<Box<dyn Future<Output = StoreResult<Vec<Session>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Returns sessions matching the filter, paginated. Read more
Source§fn list_messages_paginated<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 Uuid,
pagination: Pagination,
) -> Pin<Box<dyn Future<Output = StoreResult<Vec<MessageRecord>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list_messages_paginated<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 Uuid,
pagination: Pagination,
) -> Pin<Box<dyn Future<Output = StoreResult<Vec<MessageRecord>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Returns messages for a session, paginated. Read more
Source§fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Checks connectivity to the backend. Read more
Source§fn get_latest_compaction<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = StoreResult<Option<MessageRecord>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_latest_compaction<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = StoreResult<Option<MessageRecord>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Returns the most recent compaction user message for a session. Read more
Source§fn mark_compacted<'life0, 'life1, 'async_trait>(
&'life0 self,
_message_id: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = StoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn mark_compacted<'life0, 'life1, 'async_trait>(
&'life0 self,
_message_id: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = StoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Marks a message as compacted, setting its
is_summary flag. Read moreAuto Trait Implementations§
impl !Freeze for MemorySessionStore
impl !RefUnwindSafe for MemorySessionStore
impl Send for MemorySessionStore
impl Sync for MemorySessionStore
impl Unpin for MemorySessionStore
impl UnsafeUnpin for MemorySessionStore
impl UnwindSafe for MemorySessionStore
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