Skip to main content

Service

Trait Service 

Source
pub trait Service<Req = ()> {
    type Response;
    type Error;

    // Required method
    fn call(
        &self,
        req: Req,
    ) -> impl Future<Output = Result<Self::Response, Self::Error>>;
}
Expand description

Trait for simulate Fn<(&Self, Arg)> -> impl Future<Output = Result<T, E>> + '_. The function call come from stateful type that can be referenced within returned opaque future.

Required Associated Types§

Source

type Response

The Ok part of output future.

Source

type Error

The Err part of output future.

Required Methods§

Source

fn call( &self, req: Req, ) -> impl Future<Output = Result<Self::Response, Self::Error>>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for Box<dyn Error + Send + Sync>

Source§

type Response = Response<ResponseBody>

Source§

type Error = Infallible

Source§

async fn call( &self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for EncodingError

Source§

type Response = Response<ResponseBody>

Source§

type Error = Infallible

Source§

async fn call( &self, req: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for Error

Source§

type Response = Response<ResponseBody>

Source§

type Error = Infallible

Source§

async fn call( &self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for Error

Source§

type Response = Response<ResponseBody>

Source§

type Error = Infallible

Source§

async fn call( &self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for Error

Source§

type Response = Response<ResponseBody>

Source§

type Error = Infallible

Source§

async fn call( &self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for Error

Source§

type Response = Response<ResponseBody>

Source§

type Error = Infallible

Source§

async fn call( &self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for FromUtf8Error

Source§

type Response = Response<ResponseBody>

Source§

type Error = Infallible

Source§

async fn call( &self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for HandshakeError

Source§

type Response = Response<ResponseBody>

Source§

type Error = Infallible

Source§

async fn call( &self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for Infallible

Source§

type Response = Response<ResponseBody>

Source§

type Error = Infallible

Source§

async fn call( &self, _: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for MultipartError

Source§

type Response = Response<ResponseBody>

Source§

type Error = Infallible

Source§

async fn call( &self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for TooManyRequests

Source§

type Response = Response<ResponseBody>

Source§

type Error = Infallible

Source§

async fn call( &self, ctx: WebContext<'r, C, B>, ) -> Result<Self::Response, Self::Error>

Source§

impl<Arg, R> Service<Arg> for MethodNotAllowedBuilder<R>
where R: Service<Arg>,

Source§

impl<Arg, S, E> Service<Arg> for RouteObject<Arg, S, E>

Source§

type Response = S

Source§

type Error = E

Source§

async fn call( &self, arg: Arg, ) -> Result<<RouteObject<Arg, S, E> as Service<Arg>>::Response, <RouteObject<Arg, S, E> as Service<Arg>>::Error>

Source§

impl<CF, Fut, C, CErr, S, E> Service<Result<S, E>> for ContextBuilder<CF>
where CF: Fn() -> Fut, Fut: Future<Output = Result<C, CErr>>, C: 'static, CErr: Debug + 'static, E: Debug + 'static,

Source§

type Response = ContextService<C, S>

Source§

type Error = Box<dyn Debug>

Source§

async fn call( &self, res: Result<S, E>, ) -> Result<<ContextBuilder<CF> as Service<Result<S, E>>>::Response, <ContextBuilder<CF> as Service<Result<S, E>>>::Error>

Source§

impl<F, Req, T, O> Service<Req> for HandlerService<F, T, ServiceMark>
where T: FromRequest<'static, Req>, F: AsyncFn2<T, Output = O> + for<'a> AsyncFn2<<T as FromRequest<'static, Req>>::Type<'a>>, O: Responder<Req>, <T as FromRequest<'static, Req>>::Error: From<<O as Responder<Req>>::Error>,

Source§

type Response = <O as Responder<Req>>::Response

Source§

type Error = <T as FromRequest<'static, Req>>::Error

Source§

async fn call( &self, req: Req, ) -> Result<<HandlerService<F, T, ServiceMark> as Service<Req>>::Response, <HandlerService<F, T, ServiceMark> as Service<Req>>::Error>

Source§

impl<F, T> Service for HandlerService<F, T, BuilderMark>
where F: Clone,

Source§

type Response = HandlerService<F, T, ServiceMark>

Source§

type Error = Infallible

Source§

async fn call( &self, _: (), ) -> Result<<HandlerService<F, T, BuilderMark> as Service>::Response, <HandlerService<F, T, BuilderMark> as Service>::Error>

Source§

impl<FA, Io, S, E, const HEADER_LIMIT: usize, const READ_BUF_LIMIT: usize, const WRITE_BUF_LIMIT: usize> Service<Result<S, E>> for HttpServiceBuilder<Http, Io, Stream, FA, HEADER_LIMIT, READ_BUF_LIMIT, WRITE_BUF_LIMIT>
where FA: Service, <FA as Service>::Error: Debug + 'static, E: Debug + 'static,

Source§

type Response = HttpService<Http, Io, Stream, S, <FA as Service>::Response, HEADER_LIMIT, READ_BUF_LIMIT, WRITE_BUF_LIMIT>

Source§

type Error = Box<dyn Debug>

Source§

async fn call( &self, res: Result<S, E>, ) -> Result<<HttpServiceBuilder<Http, Io, Stream, FA, HEADER_LIMIT, READ_BUF_LIMIT, WRITE_BUF_LIMIT> as Service<Result<S, E>>>::Response, <HttpServiceBuilder<Http, Io, Stream, FA, HEADER_LIMIT, READ_BUF_LIMIT, WRITE_BUF_LIMIT> as Service<Result<S, E>>>::Error>

Source§

impl<I, Req> Service<Req> for Box<I>
where I: ServiceObject<Req> + ?Sized,

Source§

type Response = <I as ServiceObject<Req>>::Response

Source§

type Error = <I as ServiceObject<Req>>::Error

Source§

async fn call( &self, req: Req, ) -> Result<<Box<I> as Service<Req>>::Response, <Box<I> as Service<Req>>::Error>

Source§

impl<Io, St, FA, S, E, const HEADER_LIMIT: usize, const READ_BUF_LIMIT: usize, const WRITE_BUF_LIMIT: usize> Service<Result<S, E>> for HttpServiceBuilder<Http2, Io, St, FA, HEADER_LIMIT, READ_BUF_LIMIT, WRITE_BUF_LIMIT>
where FA: Service, <FA as Service>::Error: Debug + 'static, E: Debug + 'static,

Source§

type Response = HttpService<Http2, Io, St, S, <FA as Service>::Response, HEADER_LIMIT, READ_BUF_LIMIT, WRITE_BUF_LIMIT>

Source§

type Error = Box<dyn Debug>

Source§

async fn call( &self, res: Result<S, E>, ) -> Result<<HttpServiceBuilder<Http2, Io, St, FA, HEADER_LIMIT, READ_BUF_LIMIT, WRITE_BUF_LIMIT> as Service<Result<S, E>>>::Response, <HttpServiceBuilder<Http2, Io, St, FA, HEADER_LIMIT, READ_BUF_LIMIT, WRITE_BUF_LIMIT> as Service<Result<S, E>>>::Error>

Source§

impl<Obj, Arg> Service<Arg> for Router<Obj>
where Obj: Service<Arg>, Arg: Clone,

Source§

type Response = RouterService<<Obj as Service<Arg>>::Response>

Source§

type Error = <Obj as Service<Arg>>::Error

Source§

async fn call( &self, arg: Arg, ) -> Result<<Router<Obj> as Service<Arg>>::Response, <Router<Obj> as Service<Arg>>::Error>

Source§

impl<R, N, Req, E, const M: usize> Service<Req> for RouteService<R, N, M>
where R: Service<Req, Error = E>, N: Service<Req, Response = <R as Service<Req>>::Response, Error = RouterError<E>>, Req: BorrowReq<Method>,

Source§

type Response = <R as Service<Req>>::Response

Source§

type Error = RouterError<E>

Source§

async fn call( &self, req: Req, ) -> Result<<RouteService<R, N, M> as Service<Req>>::Response, <RouteService<R, N, M> as Service<Req>>::Error>

Source§

impl<R, Req> Service<Req> for MethodNotAllowedService<R>
where R: Service<Req>,

Source§

type Response = <R as Service<Req>>::Response

Source§

type Error = RouterError<<R as Service<Req>>::Error>

Source§

async fn call( &self, _: Req, ) -> Result<<MethodNotAllowedService<R> as Service<Req>>::Response, <MethodNotAllowedService<R> as Service<Req>>::Error>

Source§

impl<S, Arg> Service<Arg> for RouterMapErr<S>
where S: Service<Arg>,

Source§

type Response = MapErrService<<S as Service<Arg>>::Response>

Source§

type Error = <S as Service<Arg>>::Error

Source§

async fn call( &self, arg: Arg, ) -> Result<<RouterMapErr<S> as Service<Arg>>::Response, <RouterMapErr<S> as Service<Arg>>::Error>

Source§

impl<S, E> Service<Result<S, E>> for CatchUnwind

Source§

type Response = CatchUnwindService<S>

Source§

type Error = E

Source§

async fn call( &self, arg: Result<S, E>, ) -> Result<<CatchUnwind as Service<Result<S, E>>>::Response, <CatchUnwind as Service<Result<S, E>>>::Error>

Source§

impl<S, E> Service<Result<S, E>> for H3ServiceBuilder

Source§

type Response = H3Service<S>

Source§

type Error = E

Source§

async fn call( &self, res: Result<S, E>, ) -> Result<<H3ServiceBuilder as Service<Result<S, E>>>::Response, <H3ServiceBuilder as Service<Result<S, E>>>::Error>

Source§

impl<S, E> Service<Result<S, E>> for Logger

Source§

type Response = LoggerService<S>

Source§

type Error = E

Source§

async fn call( &self, res: Result<S, E>, ) -> Result<<Logger as Service<Result<S, E>>>::Response, <Logger as Service<Result<S, E>>>::Error>

Source§

impl<S, E> Service<Result<S, E>> for SocketConfig

Source§

type Response = SocketConfigService<S>

Source§

type Error = E

Source§

async fn call( &self, res: Result<S, E>, ) -> Result<<SocketConfig as Service<Result<S, E>>>::Response, <SocketConfig as Service<Result<S, E>>>::Error>

Source§

impl<S, Req> Service<Req> for Arc<S>
where S: Service<Req> + ?Sized,

Available on crate feature alloc only.
Source§

type Response = <S as Service<Req>>::Response

Source§

type Error = <S as Service<Req>>::Error

Source§

async fn call( &self, req: Req, ) -> Result<<Arc<S> as Service<Req>>::Response, <Arc<S> as Service<Req>>::Error>

Source§

impl<S, Req> Service<Req> for Pin<S>
where S: Deref, <S as Deref>::Target: Service<Req>,

Source§

type Response = <<S as Deref>::Target as Service<Req>>::Response

Source§

type Error = <<S as Deref>::Target as Service<Req>>::Error

Source§

async fn call( &self, req: Req, ) -> Result<<Pin<S> as Service<Req>>::Response, <Pin<S> as Service<Req>>::Error>

Source§

impl<S, ResB, BE> Service<(QuicStream, SocketAddr)> for H3Service<S>
where S: Service<Request<RequestExt<RequestBody>>, Response = Response<ResB>>, <S as Service<Request<RequestExt<RequestBody>>>>::Error: Debug, ResB: Body<Data = Bytes, Error = BE>, BE: Debug,

Source§

impl<St, Io, FA, S, E, const HEADER_LIMIT: usize, const READ_BUF_LIMIT: usize, const WRITE_BUF_LIMIT: usize> Service<Result<S, E>> for HttpServiceBuilder<Http1, Io, St, FA, HEADER_LIMIT, READ_BUF_LIMIT, WRITE_BUF_LIMIT>
where FA: Service, <FA as Service>::Error: Debug + 'static, E: Debug + 'static,

Source§

type Response = HttpService<Http1, Io, St, S, <FA as Service>::Response, HEADER_LIMIT, READ_BUF_LIMIT, WRITE_BUF_LIMIT>

Source§

type Error = Box<dyn Debug>

Source§

async fn call( &self, res: Result<S, E>, ) -> Result<<HttpServiceBuilder<Http1, Io, St, FA, HEADER_LIMIT, READ_BUF_LIMIT, WRITE_BUF_LIMIT> as Service<Result<S, E>>>::Response, <HttpServiceBuilder<Http1, Io, St, FA, HEADER_LIMIT, READ_BUF_LIMIT, WRITE_BUF_LIMIT> as Service<Result<S, E>>>::Error>

Source§

impl<T, S, E> Service<Result<S, E>> for Option<T>
where T: Service<Result<S, E>, Error = E>,

Source§

type Response = Pipeline<S, <T as Service<Result<S, E>>>::Response>

Source§

type Error = <T as Service<Result<S, E>>>::Error

Source§

async fn call( &self, res: Result<S, E>, ) -> Result<<Option<T> as Service<Result<S, E>>>::Response, <Option<T> as Service<Result<S, E>>>::Error>

Implementors§

Source§

impl Service for Redirect

Source§

impl<'r, C, B, T> Service<WebContext<'r, C, B>> for Html<T>
where T: Clone + Into<ResponseBody>,

Source§

impl<'r, C, B, T> Service<WebContext<'r, C, B>> for Json<T>
where T: Serialize + Clone,

Source§

impl<'r, C, B, T> Service<WebContext<'r, C, B>> for Text<T>
where T: Into<ResponseBody> + Clone,

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for BodyOverFlow

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for ErrorStatus

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for ExtensionNotFound

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for GrpcError

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for HeaderNotFound

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for InvalidHeaderValue

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for MatchError

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for MethodNotAllowed

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for ParseError

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for Redirect

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for StatusCode

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for ThreadJoinError

Source§

impl<'r, C, B> Service<WebContext<'r, C, B>> for ToStrError

Source§

impl<'r, C, ReqB, S, ResB> Service<WebContext<'r, C, ReqB>> for TowerCompatService<S>
where S: Service<Request<CompatReqBody<RequestExt<ReqB>, C>>, Response = Response<ResB>>, ResB: Body, C: Clone + 'static, ReqB: Default,

Source§

impl<'r, C> Service<WebContext<'r, C>> for xitca_web::error::Error
where C: 'static,

Source§

impl<'r, S, C, B, Res, Err> Service<WebContext<'r, C, B>> for LimitService<S>
where B: BodyStream + Default, S: for<'r2> Service<WebContext<'r2, C, LimitBody<B>>, Response = Res, Error = Err>,

Source§

type Response = Res

Source§

type Error = Err

Source§

impl<'r, S, C, B> Service<WebContext<'r, C, B>> for GrpcTimeoutService<S>
where S: for<'r2> Service<WebContext<'r2, C, B>, Response = WebResponse, Error = Error>,

Source§

impl<Arg, R, N, const M: usize> Service<Arg> for Route<R, N, M>
where R: Service<Arg>, N: Service<Arg, Error = <R as Service<Arg>>::Error>, Arg: Clone,

Source§

type Response = RouteService<<R as Service<Arg>>::Response, <N as Service<Arg>>::Response, M>

Source§

type Error = <R as Service<Arg>>::Error

Source§

impl<Arg> Service<Arg> for xitca_web::middleware::CatchUnwind
where CatchUnwind: Service<Arg>,

Source§

type Response = CatchUnwindService<<CatchUnwind as Service<Arg>>::Response>

Source§

type Error = <CatchUnwind as Service<Arg>>::Error

Source§

impl<Arg> Service<Arg> for xitca_web::middleware::Logger
where Logger: Service<Arg>,

Source§

impl<F, Req, Res, Err> Service<Req> for FnService<F>
where F: AsyncFn(Req) -> Result<Res, Err>,

Source§

type Response = Res

Source§

type Error = Err

Source§

impl<F, S, E> Service<Result<S, E>> for SyncMiddleware<F>
where F: Clone,

Source§

type Response = SyncService<F, S>

Source§

type Error = E

Source§

impl<F, S, Req> Service<Req> for xitca_web::service::pipeline::PipelineE<F, S>
where F: Service<Req>, S: Service<Req, Response = <F as Service<Req>>::Response, Error = <F as Service<Req>>::Error>,

Source§

type Response = <F as Service<Req>>::Response

Source§

type Error = <F as Service<Req>>::Error

Source§

impl<F, T, Arg> Service<Arg> for xitca_web::service::pipeline::PipelineT<F, T, BuildEnclosed>
where F: Service<Arg>, T: Service<Result<<F as Service<Arg>>::Response, <F as Service<Arg>>::Error>>,

Source§

type Response = <T as Service<Result<<F as Service<Arg>>::Response, <F as Service<Arg>>::Error>>>::Response

Source§

type Error = <T as Service<Result<<F as Service<Arg>>::Response, <F as Service<Arg>>::Error>>>::Error

Source§

impl<F> Service for ServeDir<F>
where F: AsyncFs + Clone,

Source§

type Response = ServeDirService<F>

Source§

type Error = Infallible

Source§

impl<L, S, E> Service<Result<S, E>> for xitca_web::middleware::tower_http_compat::TowerHttpCompat<L>
where L: Layer<CompatLayer<S>>,

Source§

type Response = TowerCompatService<<L as Layer<CompatLayer<S>>>::Service>

Source§

type Error = E

Source§

impl<M, S, E> Service<Result<S, E>> for TypeEraser<M>

Source§

type Response = EraserService<M, S>

Source§

type Error = E

Source§

impl<R, Arg, C> Service<Arg> for App<R, Box<dyn Fn() -> Pin<Box<dyn Future<Output = Result<C, Box<dyn Debug>>>>> + Send + Sync>>
where R: Service<Arg>,

Source§

type Response = NestAppService<C, <R as Service<Arg>>::Response>

Source§

type Error = <R as Service<Arg>>::Error

Source§

impl<R, Arg> Service<Arg> for App<R>
where R: Service<Arg>,

Source§

type Response = <R as Service<Arg>>::Response

Source§

type Error = <R as Service<Arg>>::Error

Source§

impl<S, E, F> Service<Result<S, E>> for AsyncFn<F>
where F: Clone,

Source§

type Response = Pipeline<S, F, AsyncFn>

Source§

type Error = E

Source§

impl<S, E> Service<Result<S, E>> for Compress

Source§

type Response = CompressService<S>

Source§

type Error = E

Source§

impl<S, E> Service<Result<S, E>> for Decompress

Source§

type Response = DecompressService<S>

Source§

type Error = E

Source§

impl<S, E> Service<Result<S, E>> for Group<S, E>

Source§

impl<S, E> Service<Result<S, E>> for GrpcTimeout

Source§

impl<S, E> Service<Result<S, E>> for Limit

Source§

impl<S, E> Service<Result<S, E>> for RateLimit

Source§

type Response = RateLimitService<S>

Source§

type Error = E

Source§

impl<S, E> Service<Result<S, E>> for UncheckedReady

Source§

type Response = UncheckedReadyService<S>

Source§

type Error = E

Source§

impl<S, E> Service<Result<S, E>> for WebContext

Source§

type Response = WebContextService<S>

Source§

type Error = E

Source§

impl<S, Req, F, Err> Service<Req> for xitca_web::service::pipeline::PipelineT<S, F, MapErr>
where S: Service<Req>, F: Fn(<S as Service<Req>>::Error) -> Err,

Source§

type Response = <S as Service<Req>>::Response

Source§

type Error = Err

Source§

impl<S, Req, F, Res, Err> Service<Req> for xitca_web::service::pipeline::PipelineT<S, F, AsyncFn>
where F: AsyncFn(&S, Req) -> Result<Res, Err>,

Source§

type Response = Res

Source§

type Error = Err

Source§

impl<S, Req, F, Res> Service<Req> for xitca_web::service::pipeline::PipelineT<S, F, Map>
where S: Service<Req>, F: Fn(<S as Service<Req>>::Response) -> Res,

Source§

type Response = Res

Source§

type Error = <S as Service<Req>>::Error

Source§

impl<S, Req, S1> Service<Req> for xitca_web::service::pipeline::PipelineT<S, S1, AndThen>
where S: Service<Req>, S1: Service<<S as Service<Req>>::Response, Error = <S as Service<Req>>::Error>,

Source§

type Response = <S1 as Service<<S as Service<Req>>::Response>>::Response

Source§

type Error = <S as Service<Req>>::Error

Source§

impl<S> Service for xitca_web::service::tower_http_compat::TowerHttpCompat<S>
where S: Clone,

Source§

impl<SF, Arg, SF1> Service<Arg> for xitca_web::service::pipeline::PipelineT<SF, SF1, BuildAndThen>
where SF: Service<Arg>, Arg: Clone, SF1: Service<Arg>, <SF1 as Service<Arg>>::Error: From<<SF as Service<Arg>>::Error>,

Source§

type Response = Pipeline<<SF as Service<Arg>>::Response, <SF1 as Service<Arg>>::Response, AndThen>

Source§

type Error = <SF1 as Service<Arg>>::Error

Source§

impl<T, S, E> Service<Result<S, E>> for Extension<T>
where T: Clone,

Source§

type Response = ExtensionService<S, T>

Source§

type Error = E

Source§

impl<T> Service for Html<T>
where T: Clone,

Source§

impl<T> Service for Json<T>
where T: Clone,

Source§

impl<T> Service for Text<T>
where T: Clone,