pub trait Backend: Send {
fn persist_session(
&self,
identifier: SessionIdentifier,
content: &[u8]
) -> Result<(), SessionError>;
fn read_session(
&self,
identifier: SessionIdentifier
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, SessionError>> + Send>>;
fn drop_session(
&self,
identifier: SessionIdentifier
) -> Result<(), SessionError>;
}
Expand description
A Backend
receives session data and stores it, and recalls the session data subsequently.
All session data is serialized into a Vec<u8>
which is treated as opaque by the backend. The
serialization format is subject to change and must not be relied upon by the Backend
.
Required methods
fn persist_session(
&self,
identifier: SessionIdentifier,
content: &[u8]
) -> Result<(), SessionError>
fn persist_session(
&self,
identifier: SessionIdentifier,
content: &[u8]
) -> Result<(), SessionError>
Persists a session, either creating a new session or updating an existing session.
fn read_session(
&self,
identifier: SessionIdentifier
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, SessionError>> + Send>>
fn read_session(
&self,
identifier: SessionIdentifier
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, SessionError>> + Send>>
Retrieves a session from the underlying storage.
The returned future will resolve to an Option<Vec<u8>>
on success, where a value of
None
indicates that the session is not available for use and a new session should be
established.
fn drop_session(
&self,
identifier: SessionIdentifier
) -> Result<(), SessionError>
fn drop_session(
&self,
identifier: SessionIdentifier
) -> Result<(), SessionError>
Drops a session from the underlying storage.