pub struct InMemorySessionStore { /* private fields */ }Expand description
In-memory session storage implementation
This implementation stores sessions in a HashMap protected by an async RwLock, making it thread-safe for concurrent access. It’s suitable for development, testing, and single-instance deployments.
§Examples
use talk::{InMemorySessionStore, Session};
use talk::storage::SessionStore;
use talk::types::AgentId;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let store = InMemorySessionStore::new();
let session = Session::new(AgentId::new());
let session_id = store.create(session).await?;
let retrieved = store.get(&session_id).await?;
assert!(retrieved.is_some());
Ok(())
}Implementations§
Trait Implementations§
Source§impl Clone for InMemorySessionStore
impl Clone for InMemorySessionStore
Source§fn clone(&self) -> InMemorySessionStore
fn clone(&self) -> InMemorySessionStore
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for InMemorySessionStore
impl Debug for InMemorySessionStore
Source§impl Default for InMemorySessionStore
impl Default for InMemorySessionStore
Source§impl SessionStore for InMemorySessionStore
impl SessionStore for InMemorySessionStore
Source§fn create<'life0, 'async_trait>(
&'life0 self,
session: Session,
) -> Pin<Box<dyn Future<Output = Result<SessionId, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn create<'life0, 'async_trait>(
&'life0 self,
session: Session,
) -> Pin<Box<dyn Future<Output = Result<SessionId, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Create a new session in the store Read more
Source§fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = Result<Option<Session>, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = Result<Option<Session>, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get a session by ID Read more
Source§fn update<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SessionId,
session: Session,
) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn update<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SessionId,
session: Session,
) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Update an existing session Read more
Source§fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 SessionId,
) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Delete a session by ID Read more
Auto Trait Implementations§
impl Freeze for InMemorySessionStore
impl !RefUnwindSafe for InMemorySessionStore
impl Send for InMemorySessionStore
impl Sync for InMemorySessionStore
impl Unpin for InMemorySessionStore
impl !UnwindSafe for InMemorySessionStore
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