use std::path::PathBuf;
use anyhow::Result;
use http::Response;
use http::response::Parts;
use http_body::Body;
use http_cache_semantics::CachePolicy;
use crate::body::CacheBody;
mod default;
pub use default::*;
pub struct StoredResponse<B: Body> {
pub response: Response<CacheBody<B>>,
pub policy: CachePolicy,
pub digest: String,
}
pub trait CacheStorage: Send + Sync + 'static {
fn get<B: Body + Send>(
&self,
key: &str,
) -> impl Future<Output = Result<Option<StoredResponse<B>>>> + Send;
fn put(
&self,
key: &str,
parts: &Parts,
policy: &CachePolicy,
digest: &str,
) -> impl Future<Output = Result<()>> + Send;
fn store<B: Body + Send>(
&self,
key: String,
parts: Parts,
body: B,
policy: CachePolicy,
) -> impl Future<Output = Result<Response<CacheBody<B>>>> + Send;
fn delete(&self, key: &str) -> impl Future<Output = Result<()>> + Send;
fn body_path(&self, digest: &str) -> PathBuf;
}