Trait Service

Source
pub trait Service<Request>:
    Sized
    + Send
    + Sync
    + 'static {
    type Response: Send + 'static;
    type Error: Send + Sync + 'static;

    // Required method
    fn call(
        &self,
        request: Request,
    ) -> impl Future<Output = Result<Self::Response, Self::Error>> + Send + '_;

    // Provided method
    fn boxed(self) -> BoxService<Request, Self::Response, Self::Error> { ... }
}

Required Associated Types§

Source

type Response: Send + 'static

Responses given by the service.

Source

type Error: Send + Sync + 'static

Errors produced by the service.

Required Methods§

Source

fn call( &self, request: Request, ) -> impl Future<Output = Result<Self::Response, Self::Error>> + Send + '_

Process the request and return the response asynchronously.

Provided Methods§

Source

fn boxed(self) -> BoxService<Request, Self::Response, Self::Error>

Box this service to allow for dynamic dispatch.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<S, Request> Service<Request> for &'static S
where S: Service<Request>,

Source§

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

Source§

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

Source§

fn call( &self, request: Request, ) -> impl Future<Output = Result<Self::Response, Self::Error>> + Send + '_

Source§

impl<S, Request> Service<Request> for Box<S>
where S: Service<Request>,

Source§

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

Source§

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

Source§

fn call( &self, request: Request, ) -> impl Future<Output = Result<Self::Response, Self::Error>> + Send + '_

Source§

impl<S, Request> Service<Request> for Arc<S>
where S: Service<Request>,

Source§

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

Source§

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

Source§

fn call( &self, request: Request, ) -> impl Future<Output = Result<Self::Response, Self::Error>> + Send + '_

Implementors§

Source§

impl<F, Request, R, Response, E> Service<Request> for FnService<F, Request, R, Response, E>
where F: Fn(Request) -> R + Send + Sync + 'static, R: Future<Output = Result<Response, E>> + Send + 'static, Response: Send + 'static, E: Send + Sync + 'static, Request: 'static,

Source§

type Response = Response

Source§

type Error = E

Source§

impl<Request, Response, Error> Service<Request> for BoxService<Request, Response, Error>
where Request: 'static, Response: Send + 'static, Error: Send + Sync + 'static,

Source§

type Response = Response

Source§

type Error = Error

Source§

impl<S, F, Request, R> Service<Request> for MapRequest<S, F>
where S: Service<Request> + 'static, Request: Send + 'static, F: FnOnce(Request) -> R + Clone + Sync + Send + 'static, R: Future<Output = Result<Request, S::Error>> + Send + 'static,

Source§

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

Source§

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

Source§

impl<S, F, Request, R> Service<Request> for MapResponse<S, F>
where S: Service<Request> + 'static, Request: Send + 'static, F: FnOnce(Result<S::Response, S::Error>) -> R + Clone + Sync + Send + 'static, R: Future<Output = Result<S::Response, S::Error>> + Send + 'static,

Source§

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

Source§

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