pub mod document;
mod noop;
mod status;
use std::future::Future;
pub use noop::Noop;
pub use status::StatusPolicy;
use crate::Result;
use crate::http::{Request, Response};
use crate::identity::Identity;
pub trait Backend: Send + Sync + 'static {
type Session: Session;
fn connect(&self) -> impl Future<Output = Result<Self::Session>> + Send;
fn connect_as(
&self,
identity: &Identity,
) -> impl Future<Output = Result<Self::Session>> + Send {
let supported = identity.require_no_proxy();
async move {
supported?;
self.connect().await
}
}
}
pub trait Session: Send + Sync + 'static {
fn fetch(&self, request: &Request) -> impl Future<Output = Result<Response>> + Send;
fn document(&self) -> Option<&dyn document::Document> {
None
}
}