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§
Sourcetype MappedResponse
type MappedResponse
Expected response type for this state request.
Required Methods§
Sourcefn map_request(self) -> Request
fn map_request(self) -> Request
Maps the request type to a Request.
Sourcefn map_response(response: Response) -> Self::MappedResponse
fn map_response(response: Response) -> Self::MappedResponse
Maps the expected Response variant for this request to the mapped response type.
Provided Methods§
Sourceasync fn mapped_oneshot<State>(
self,
state: &mut State,
) -> Result<Self::MappedResponse, LayeredStateError<Self::Error>>
async fn mapped_oneshot<State>( self, state: &mut State, ) -> Result<Self::MappedResponse, LayeredStateError<Self::Error>>
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.