pub struct MemoryStore { /* private fields */ }Expand description
Keeps everything in memory behind one mutex. Nothing survives a restart and nothing is shared between processes, so use it for tests, development and single-instance apps only.
Implementations§
Source§impl MemoryStore
impl MemoryStore
Sourcepub fn events(&self) -> Vec<SessionEvent>
pub fn events(&self) -> Vec<SessionEvent>
Every recorded event, oldest first.
Sourcepub fn session_count(&self) -> usize
pub fn session_count(&self) -> usize
Number of stored sessions, including expired ones not yet purged.
Trait Implementations§
Source§impl Debug for MemoryStore
impl Debug for MemoryStore
Source§impl Default for MemoryStore
impl Default for MemoryStore
Source§impl SessionStore for MemoryStore
impl SessionStore for MemoryStore
Source§fn insert_session(
&self,
session: &SessionRecord,
token: &TokenHash,
) -> impl Future<Output = Result<(), StoreError>> + Send
fn insert_session( &self, session: &SessionRecord, token: &TokenHash, ) -> impl Future<Output = Result<(), StoreError>> + Send
Stores a new session with
token as its current token (issued_at = created_at,
unused, not superseded).Source§fn find_by_token(
&self,
token: &TokenHash,
) -> impl Future<Output = Result<Option<TokenLookup>, StoreError>> + Send
fn find_by_token( &self, token: &TokenHash, ) -> impl Future<Output = Result<Option<TokenLookup>, StoreError>> + Send
Finds the session holding
token, current or superseded.Source§fn apply(
&self,
update: &SessionUpdate,
) -> impl Future<Output = Result<bool, StoreError>> + Send
fn apply( &self, update: &SessionUpdate, ) -> impl Future<Output = Result<bool, StoreError>> + Send
Applies
update atomically, in this order: Read moreSource§fn delete_session(
&self,
session_id: Uuid,
) -> impl Future<Output = Result<bool, StoreError>> + Send
fn delete_session( &self, session_id: Uuid, ) -> impl Future<Output = Result<bool, StoreError>> + Send
Deletes a session and its tokens. Returns whether it existed.
Source§fn delete_subject_sessions(
&self,
subject: &str,
) -> impl Future<Output = Result<Vec<Uuid>, StoreError>> + Send
fn delete_subject_sessions( &self, subject: &str, ) -> impl Future<Output = Result<Vec<Uuid>, StoreError>> + Send
Deletes every session of
subject (canonical JSON). Returns the ids it deleted.Source§fn list_subject_sessions(
&self,
subject: &str,
) -> impl Future<Output = Result<Vec<SessionRecord>, StoreError>> + Send
fn list_subject_sessions( &self, subject: &str, ) -> impl Future<Output = Result<Vec<SessionRecord>, StoreError>> + Send
Every session of
subject (canonical JSON), including expired ones not yet purged.Source§fn delete_expired(
&self,
now: DateTime<Utc>,
idle_cutoff: DateTime<Utc>,
) -> impl Future<Output = Result<u64, StoreError>> + Send
fn delete_expired( &self, now: DateTime<Utc>, idle_cutoff: DateTime<Utc>, ) -> impl Future<Output = Result<u64, StoreError>> + Send
Deletes sessions with
expires_at <= now or last_seen_at <= idle_cutoff. Returns how
many.Source§fn record_event(
&self,
event: &SessionEvent,
) -> impl Future<Output = Result<(), StoreError>> + Send
fn record_event( &self, event: &SessionEvent, ) -> impl Future<Output = Result<(), StoreError>> + Send
Appends a security event. Stores without an event log may discard it.
Source§fn delete_events_before(
&self,
cutoff: DateTime<Utc>,
) -> impl Future<Output = Result<u64, StoreError>> + Send
fn delete_events_before( &self, cutoff: DateTime<Utc>, ) -> impl Future<Output = Result<u64, StoreError>> + Send
Deletes events with
at < cutoff. Returns how many. Also deletes event claims older
than cutoff.Source§fn claim_event(
&self,
scope: ClaimScope<'_>,
kind: EventKind,
now: DateTime<Utc>,
window: TimeDelta,
) -> impl Future<Output = Result<bool, StoreError>> + Send
fn claim_event( &self, scope: ClaimScope<'_>, kind: EventKind, now: DateTime<Utc>, window: TimeDelta, ) -> impl Future<Output = Result<bool, StoreError>> + Send
Claims the right to report a
kind event for scope, for deduplication across
processes. Succeeds (true) unless a claim for the same scope and kind was made after
now - window, and records now as the new claim when it does. Session and subject
claims are independent. Must be atomic across processes. Read moreAuto Trait Implementations§
impl !Freeze for MemoryStore
impl RefUnwindSafe for MemoryStore
impl Send for MemoryStore
impl Sync for MemoryStore
impl Unpin for MemoryStore
impl UnsafeUnpin for MemoryStore
impl UnwindSafe for MemoryStore
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
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> ⓘ
Converts
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> ⓘ
Converts
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