mod and_then;
pub use and_then::AndThen;
mod boxed;
pub use boxed::{ArcService, BoxCloneService, BoxService};
mod ext;
pub use ext::ServiceExt;
mod map_err;
pub use map_err::MapErr;
mod map_request;
pub use map_request::MapRequest;
mod map_response;
pub use map_response::MapResponse;
mod map_result;
pub use map_result::MapResult;
mod or_else;
pub use or_else::OrElse;
mod service_fn;
pub use service_fn::{service_fn, ServiceFn};
mod then;
pub use then::Then;
use std::future::Future;
use std::sync::Arc;
pub trait Service<Req>: Send + Sync {
type Response;
type Error;
fn call(&self, req: Req) -> impl Future<Output = Result<Self::Response, Self::Error>> + Send;
}
impl<S, Req> Service<Req> for &mut S
where
S: Service<Req> + ?Sized,
{
type Response = S::Response;
type Error = S::Error;
fn call(&self, req: Req) -> impl Future<Output = Result<Self::Response, Self::Error>> + Send {
S::call(self, req)
}
}
impl<S, Req> Service<Req> for &S
where
S: Service<Req> + ?Sized,
{
type Response = S::Response;
type Error = S::Error;
fn call(&self, req: Req) -> impl Future<Output = Result<Self::Response, Self::Error>> + Send {
S::call(self, req)
}
}
impl<S, Req> Service<Req> for Box<S>
where
S: Service<Req> + ?Sized,
{
type Response = S::Response;
type Error = S::Error;
fn call(&self, req: Req) -> impl Future<Output = Result<Self::Response, Self::Error>> + Send {
S::call(self, req)
}
}
impl<S, Req> Service<Req> for Arc<S>
where
S: Service<Req> + ?Sized,
{
type Response = S::Response;
type Error = S::Error;
fn call(&self, req: Req) -> impl Future<Output = Result<Self::Response, Self::Error>> + Send {
S::call(self, req)
}
}