service_layer_rs::service

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.

Object Safety§

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