pub struct InMemorySessionStorage { /* private fields */ }Expand description
In-memory storage for sessions and events (SSE compliant)
Implementations§
Source§impl InMemorySessionStorage
impl InMemorySessionStorage
Sourcepub fn with_config(config: InMemoryConfig) -> Self
pub fn with_config(config: InMemoryConfig) -> Self
Create new in-memory session storage with custom configuration
Sourcepub async fn stats(&self) -> InMemoryStats
pub async fn stats(&self) -> InMemoryStats
Get current statistics
Trait Implementations§
Source§impl Clone for InMemorySessionStorage
impl Clone for InMemorySessionStorage
Source§fn clone(&self) -> InMemorySessionStorage
fn clone(&self) -> InMemorySessionStorage
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 InMemorySessionStorage
impl Debug for InMemorySessionStorage
Source§impl Default for InMemorySessionStorage
impl Default for InMemorySessionStorage
Source§impl SessionStorage for InMemorySessionStorage
impl SessionStorage for InMemorySessionStorage
Source§type Error = SessionStorageError
type Error = SessionStorageError
Error type for storage operations
Source§fn backend_name(&self) -> &'static str
fn backend_name(&self) -> &'static str
Get the backend name for logging and debugging
Source§fn create_session<'life0, 'async_trait>(
&'life0 self,
capabilities: ServerCapabilities,
) -> Pin<Box<dyn Future<Output = Result<SessionInfo, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn create_session<'life0, 'async_trait>(
&'life0 self,
capabilities: ServerCapabilities,
) -> Pin<Box<dyn Future<Output = Result<SessionInfo, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Create a new session with automatically generated UUID v7 Read more
Source§fn create_session_with_id<'life0, 'async_trait>(
&'life0 self,
session_id: String,
capabilities: ServerCapabilities,
) -> Pin<Box<dyn Future<Output = Result<SessionInfo, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn create_session_with_id<'life0, 'async_trait>(
&'life0 self,
session_id: String,
capabilities: ServerCapabilities,
) -> Pin<Box<dyn Future<Output = Result<SessionInfo, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Create session with a specific session ID Read more
Source§fn get_session<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<SessionInfo>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_session<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<SessionInfo>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get session by ID
Source§fn update_session<'life0, 'async_trait>(
&'life0 self,
session_info: SessionInfo,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn update_session<'life0, 'async_trait>(
&'life0 self,
session_info: SessionInfo,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Update entire session info
Source§fn set_session_state<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
key: &'life2 str,
value: Value,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn set_session_state<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
key: &'life2 str,
value: Value,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Update session state value
Source§fn get_session_state<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get_session_state<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Get session state value
Source§fn remove_session_state<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn remove_session_state<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Remove session state value
Source§fn delete_session<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete_session<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Delete session completely
Source§fn list_sessions<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_sessions<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
List all session IDs
Source§fn store_event<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
event: SseEvent,
) -> Pin<Box<dyn Future<Output = Result<SseEvent, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn store_event<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
event: SseEvent,
) -> Pin<Box<dyn Future<Output = Result<SseEvent, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Store an event for a session (assigns unique event ID)
Source§fn get_events_after<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
after_event_id: u64,
) -> Pin<Box<dyn Future<Output = Result<Vec<SseEvent>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_events_after<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
after_event_id: u64,
) -> Pin<Box<dyn Future<Output = Result<Vec<SseEvent>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get events after a specific event ID (for resumability)
Source§fn get_recent_events<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SseEvent>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_recent_events<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<SseEvent>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get recent events (for initial connection)
Source§fn delete_events_before<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
before_event_id: u64,
) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete_events_before<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
before_event_id: u64,
) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Delete old events (cleanup)
Source§fn expire_sessions<'life0, 'async_trait>(
&'life0 self,
older_than: SystemTime,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn expire_sessions<'life0, 'async_trait>(
&'life0 self,
older_than: SystemTime,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Remove expired sessions (returns list of removed session IDs)
Source§fn session_count<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn session_count<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get session count for monitoring
Auto Trait Implementations§
impl Freeze for InMemorySessionStorage
impl !RefUnwindSafe for InMemorySessionStorage
impl Send for InMemorySessionStorage
impl Sync for InMemorySessionStorage
impl Unpin for InMemorySessionStorage
impl !UnwindSafe for InMemorySessionStorage
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