Skip to main content

InMemorySessionRepository

Type Alias InMemorySessionRepository 

Source
pub type InMemorySessionRepository<Session> = RwLock<HashMap<Endpoint, Session>>;
Expand description

An in-memory session repository implementation that stores sessions in a HashMap protected by an RwLock. This is a simple implementation that can be used for testing or in scenarios where persistence is not required.

Aliased Type§

pub struct InMemorySessionRepository<Session> { /* private fields */ }

Trait Implementations§

Source§

impl<Session> SessionRepository<Session> for InMemorySessionRepository<Session>
where Session: Clone + Send + Sync + 'static,

Source§

type GetError = ()

Error returned when a session could not be read.
Source§

type SaveError = ()

Error returned when a session could not be persisted.
Source§

type RemoveError = ()

Error returned when a session could not be removed.
Source§

async fn get(&self, destination: Endpoint) -> Result<Option<Session>, ()>

Load the session for the given destination, if one exists.
Source§

async fn save(&self, destination: Endpoint, session: Session) -> Result<(), ()>

Store (or overwrite) the session for the given destination.
Source§

async fn remove(&self, destination: Endpoint) -> Result<(), ()>

Remove the session for the given destination, if one exists.