use crate::FlashMessage;
use actix_web::dev::ResponseHead;
use actix_web::HttpRequest;
pub trait FlashMessageStore: Send + Sync {
fn load(&self, request: &HttpRequest) -> Result<Vec<FlashMessage>, LoadError>;
fn store(
&self,
messages: &[FlashMessage],
request: HttpRequest,
response: &mut ResponseHead,
) -> Result<(), StoreError>;
}
#[derive(thiserror::Error, Debug)]
pub enum LoadError {
#[error("Failed to deserialize incoming flash messages")]
DeserializationError(#[source] anyhow::Error),
#[error("The content of incoming flash messages failed a cryptographic integrity check (e.g. signature verification)")]
IntegrityCheckFailed(#[source] anyhow::Error),
#[error("Something went wrong when extracting incoming flash messages")]
GenericError(#[source] anyhow::Error),
}
#[derive(thiserror::Error, Debug)]
pub enum StoreError {
#[error("Failed to serialize outgoing flash messages")]
SerializationError(#[source] anyhow::Error),
#[error("Outgoing flash messages, when serialised, exceeded the store size limit")]
SizeLimitExceeded(#[source] anyhow::Error),
#[error("Something went wrong when flushing outgoing flash messages")]
GenericError(#[source] anyhow::Error),
}