use std::fmt;
use std::future::Future;
use std::pin::Pin;
use super::Request as AsyncRequest;
use crate::client::ClientOptions;
use crate::Result;
pub trait AsyncClient: Clone + Send + Sync + 'static {
type Response: AsyncResponse + Send;
fn describe(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "AsyncClient")
}
fn request(&self, req: AsyncRequest) -> impl Future<Output = Result<Self::Response>> + Send;
}
pub trait AsyncBackend: Send + Sync + 'static {
type AsyncClient: AsyncClient;
fn create_async_client(
&self,
options: ClientOptions,
) -> impl Future<Output = Result<Self::AsyncClient>> + Send;
}
pub trait AsyncResponse: super::MaybeAsyncRead + Send + Sync + 'static {
fn describe(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "AsyncResponse")
}
fn status(&self) -> u16;
fn content_length(&self) -> Option<u64>;
fn get_header(&self, header: &str) -> Result<Vec<String>>;
fn text(self: Pin<&mut Self>) -> impl Future<Output = Result<String>> + Send;
fn bytes(self: Pin<&mut Self>) -> impl Future<Output = Result<Vec<u8>>> + Send;
}