InMemorySessionStorage

Struct InMemorySessionStorage 

Source
pub struct InMemorySessionStorage { /* private fields */ }
Expand description

In-memory storage for sessions and events (SSE compliant)

Implementations§

Source§

impl InMemorySessionStorage

Source

pub fn new() -> Self

Create new in-memory session storage with default configuration

Source

pub fn with_config(config: InMemoryConfig) -> Self

Create new in-memory session storage with custom configuration

Source

pub async fn stats(&self) -> InMemoryStats

Get current statistics

Trait Implementations§

Source§

impl Clone for InMemorySessionStorage

Source§

fn clone(&self) -> InMemorySessionStorage

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for InMemorySessionStorage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for InMemorySessionStorage

Source§

fn default() -> Self

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

impl SessionStorage for InMemorySessionStorage

Source§

type Error = SessionStorageError

Error type for storage operations
Source§

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

Get session count for monitoring
Source§

fn event_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 total event count across all sessions
Source§

fn maintenance<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Perform maintenance tasks (compaction, cleanup, etc.)

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more