pub trait HttpParser {
type ApiError: DeserializeOwned;
type OutputError: From<SocketError>;
// Required method
fn parse_api_error(
&self,
status: StatusCode,
error: Self::ApiError,
) -> Self::OutputError;
// Provided method
fn parse<Response>(
&self,
status: StatusCode,
payload: &[u8],
) -> Result<Response, Self::OutputError>
where Response: DeserializeOwned { ... }
}Expand description
Utilised by a RestClient to deserialise
RestRequest::Response, and upon failure parses API errors
returned from the server.
Required Associated Types§
type ApiError: DeserializeOwned
type OutputError: From<SocketError>
Required Methods§
Sourcefn parse_api_error(
&self,
status: StatusCode,
error: Self::ApiError,
) -> Self::OutputError
fn parse_api_error( &self, status: StatusCode, error: Self::ApiError, ) -> Self::OutputError
If parse fails to deserialise the Ok(Response), this function parses
to parse the API Self::ApiError associated with the response.
Provided Methods§
Sourcefn parse<Response>(
&self,
status: StatusCode,
payload: &[u8],
) -> Result<Response, Self::OutputError>where
Response: DeserializeOwned,
fn parse<Response>(
&self,
status: StatusCode,
payload: &[u8],
) -> Result<Response, Self::OutputError>where
Response: DeserializeOwned,
Attempt to parse a StatusCode & bytes payload into a deserialisable Response.
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.