pub trait ResponseHttpConvert<Request, Response>where
Request: Clone,
Response: ResponseHttpConvert<Request, Response>,{
// Required methods
fn from_http_response<'life0, 'async_trait>(
response: ModalHttpResponse,
original_request: &'life0 Request,
) -> Pin<Box<dyn Future<Output = Result<Option<ServiceResponse<Response>>, ProtocolError>> + Send + 'async_trait>>
where 'life0: 'async_trait;
fn to_http_response(
response: ServiceResponse<Response>,
) -> Result<Option<ModalHttpResponse>, ProtocolError>;
}
Expand description
A response that can convert to and from a ModalHttpResponse
.
Required Methods§
Sourcefn from_http_response<'life0, 'async_trait>(
response: ModalHttpResponse,
original_request: &'life0 Request,
) -> Pin<Box<dyn Future<Output = Result<Option<ServiceResponse<Response>>, ProtocolError>> + Send + 'async_trait>>where
'life0: 'async_trait,
fn from_http_response<'life0, 'async_trait>(
response: ModalHttpResponse,
original_request: &'life0 Request,
) -> Pin<Box<dyn Future<Output = Result<Option<ServiceResponse<Response>>, ProtocolError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Deserializes a ModalHttpResponse
into ServiceResponse<Response>
.
Returns a protocol error if the response conversion fails (i.e.
response validation fails, unexpected error, etc.). A reference to the associated
request is provided, in case it’s helpful. Returns None
if the response type is unknown or unsupported
for remote host scenarios, which is synonymous with a “not found” error.
Sourcefn to_http_response(
response: ServiceResponse<Response>,
) -> Result<Option<ModalHttpResponse>, ProtocolError>
fn to_http_response( response: ServiceResponse<Response>, ) -> Result<Option<ModalHttpResponse>, ProtocolError>
Serializes a Response
into a ModalHttpResponse
.
Returns None
if the response type is unsupported, which is synonymous
with a “not found” error.
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.