#[cfg(feature = "actix")]
pub mod actix;
#[cfg(feature = "browser")]
pub mod browser;
#[cfg(feature = "generic")]
pub mod generic;
#[cfg(feature = "axum-no-default")]
pub mod http;
#[cfg(feature = "reqwest")]
pub mod reqwest;
use bytes::Bytes;
use futures::Stream;
use std::future::Future;
pub trait TryRes<E>
where
Self: Sized,
{
fn try_from_string(content_type: &str, data: String) -> Result<Self, E>;
fn try_from_bytes(content_type: &str, data: Bytes) -> Result<Self, E>;
fn try_from_stream(
content_type: &str,
data: impl Stream<Item = Result<Bytes, E>> + Send + 'static,
) -> Result<Self, E>;
}
pub trait Res {
fn error_response(path: &str, err: String) -> Self;
fn redirect(&mut self, path: &str);
}
pub trait ClientRes<E> {
fn try_into_string(self) -> impl Future<Output = Result<String, E>> + Send;
fn try_into_bytes(self) -> impl Future<Output = Result<Bytes, E>> + Send;
fn try_into_stream(
self,
) -> Result<impl Stream<Item = Result<Bytes, E>> + Send + Sync + 'static, E>;
fn status(&self) -> u16;
fn status_text(&self) -> String;
fn location(&self) -> String;
fn has_redirect(&self) -> bool;
}
pub struct BrowserMockRes;
impl<E> TryRes<E> for BrowserMockRes {
fn try_from_string(_content_type: &str, _data: String) -> Result<Self, E> {
unreachable!()
}
fn try_from_bytes(_content_type: &str, _data: Bytes) -> Result<Self, E> {
unreachable!()
}
fn try_from_stream(
_content_type: &str,
_data: impl Stream<Item = Result<Bytes, E>>,
) -> Result<Self, E> {
unreachable!()
}
}
impl Res for BrowserMockRes {
fn error_response(_path: &str, _err: String) -> Self {
unreachable!()
}
fn redirect(&mut self, _path: &str) {
unreachable!()
}
}