use std::{
fmt::{self, Debug},
hash::Hash,
};
use async_trait::async_trait;
use http::Request;
use crate::types::http::{CacheError, Error};
#[cfg_attr(test, mockall::automock)]
#[async_trait]
pub trait Client: Send + Sync + fmt::Debug {
async fn execute(&self, req: reqwest::Request) -> Result<reqwest::Response, reqwest::Error>;
}
#[async_trait]
pub trait ClientHttp<B1, B2 = axum::body::Body>: Send + Sync + fmt::Debug {
async fn execute(&self, req: http::Request<B1>) -> Result<http::Response<B2>, Error>;
}
pub trait KeyExtractor: Clone + Send + Sync + Debug + 'static {
type Key: Clone + Send + Sync + Debug + Hash + Eq + 'static;
fn extract<T>(&self, req: &Request<T>) -> Result<Self::Key, CacheError>;
}
pub trait CustomBypassReason:
Debug + Clone + std::fmt::Display + Into<&'static str> + PartialEq + Eq + Send + Sync + 'static
{
}
pub trait Bypasser: Clone + Send + Sync + Debug + 'static {
type BypassReason: CustomBypassReason;
fn bypass<T>(&self, req: &Request<T>) -> Result<Option<Self::BypassReason>, CacheError>;
}