pub struct SessionStore { /* private fields */ }Expand description
Manages client sessions keyed by public key (hex).
Backed by an LRU cache so memory usage is bounded.
Implementations§
Source§impl SessionStore
impl SessionStore
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a store with the default capacity (DEFAULT_MAX_SESSIONS).
Sourcepub fn with_capacity(max_sessions: usize) -> Self
pub fn with_capacity(max_sessions: usize) -> Self
Create a store with a specific maximum number of sessions.
Sourcepub fn set_eviction_callback(&mut self, cb: EvictionCallback)
pub fn set_eviction_callback(&mut self, cb: EvictionCallback)
Register a callback that fires when a session is evicted from the LRU.
Sourcepub fn eviction_callback(&self) -> Option<EvictionCallback>
pub fn eviction_callback(&self) -> Option<EvictionCallback>
Clone the eviction callback (cheap Arc clone) for use outside the lock.
Sourcepub async fn get_or_create_session(
&self,
client_pubkey: &str,
is_encrypted: bool,
event_routes: &ServerEventRouteStore,
) -> bool
pub async fn get_or_create_session( &self, client_pubkey: &str, is_encrypted: bool, event_routes: &ServerEventRouteStore, ) -> bool
Get an existing session or create a new one. Returns true if a new session was created.
event_routes is consulted during eviction safety: if the evicted client
still has active routes, the session is recreated with clean state
(matching TS SDK’s hasActiveRoutesForClient check).
Sourcepub async fn get_session(&self, client_pubkey: &str) -> Option<SessionSnapshot>
pub async fn get_session(&self, client_pubkey: &str) -> Option<SessionSnapshot>
Get a read-only snapshot of session fields.
Returns None if the session does not exist.
Sourcepub async fn mark_initialized(&self, client_pubkey: &str) -> bool
pub async fn mark_initialized(&self, client_pubkey: &str) -> bool
Mark a session as initialized. Returns true if the session existed.
Mark that common tags have been sent for this session.
Sourcepub async fn remove_session(&self, client_pubkey: &str) -> bool
pub async fn remove_session(&self, client_pubkey: &str) -> bool
Remove a session. Returns true if it existed.
Sourcepub async fn session_count(&self) -> usize
pub async fn session_count(&self) -> usize
Number of active sessions.
Sourcepub async fn get_all_sessions(&self) -> Vec<(String, SessionSnapshot)>
pub async fn get_all_sessions(&self) -> Vec<(String, SessionSnapshot)>
Return a snapshot of all sessions as (client_pubkey, snapshot) pairs.
Trait Implementations§
Source§impl Clone for SessionStore
impl Clone for SessionStore
Source§fn clone(&self) -> SessionStore
fn clone(&self) -> SessionStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SessionStore
impl !RefUnwindSafe for SessionStore
impl Send for SessionStore
impl Sync for SessionStore
impl Unpin for SessionStore
impl UnsafeUnpin for SessionStore
impl !UnwindSafe for SessionStore
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more