pub(super) mod memory;
use std::panic::RefUnwindSafe;
use std::pin::Pin;
use futures::prelude::*;
use crate::middleware::session::{SessionError, SessionIdentifier};
pub trait NewBackend: Sync + Clone + RefUnwindSafe {
type Instance: Backend + Send + 'static;
fn new_backend(&self) -> anyhow::Result<Self::Instance>;
}
pub type SessionFuture = dyn Future<Output = Result<Option<Vec<u8>>, SessionError>> + Send;
pub trait Backend: Send {
fn persist_session(
&self,
identifier: SessionIdentifier,
content: &[u8],
) -> Result<(), SessionError>;
fn read_session(&self, identifier: SessionIdentifier) -> Pin<Box<SessionFuture>>;
fn drop_session(&self, identifier: SessionIdentifier) -> Result<(), SessionError>;
}