MappedRequest

Trait MappedRequest 

Source
pub trait MappedRequest:
    Sized
    + Send
    + 'static {
    type MappedResponse;
    type Error: Error + Display + 'static;

    // Required methods
    fn map_request(self) -> Request;
    fn map_response(response: Response) -> Self::MappedResponse;

    // Provided method
    async fn mapped_oneshot<State>(
        self,
        state: &mut State,
    ) -> Result<Self::MappedResponse, LayeredStateError<Self::Error>>
       where State: Service<Request, Response = Response, Error = BoxError>,
             State::Future: Send { ... }
}
Expand description

Helper trait for convenient access to expected response and error types.

Required Associated Types§

Source

type MappedResponse

Expected response type for this state request.

Source

type Error: Error + Display + 'static

Expected error type for this state request.

Required Methods§

Source

fn map_request(self) -> Request

Maps the request type to a Request.

Source

fn map_response(response: Response) -> Self::MappedResponse

Maps the expected Response variant for this request to the mapped response type.

Provided Methods§

Source

async fn mapped_oneshot<State>( self, state: &mut State, ) -> Result<Self::MappedResponse, LayeredStateError<Self::Error>>
where State: Service<Request, Response = Response, Error = BoxError>, State::Future: Send,

Accepts a state service to call, maps this request to a Request, waits for the state to be ready, calls the state with the mapped request, then maps the success or error response to the expected response or error type for this request.

Returns a Result<MappedResponse, LayeredServicesError<RequestError>>.

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.

Implementors§