Trait under::IntoResponse

source ·
pub trait IntoResponse {
    fn into_response(self) -> Result<Response, Error>;
}
Expand description

Converts the current type into a crate::Response.

This assumes that the conversion into a response is fallible (as it often is). This is used instead of TryFrom because TryFrom<Result<T, E>> is not implemented for Result<T, E>.

This uses anyhow::Error as the error type for a few reasons:

  1. anyhow::Error does not implement std::error::Error.
  2. std::convert::Infallible/! does not implement Into<T>/From<T>.
  3. I can’t figure out how to reconcile the two such that IntoResponse can be implemented for Result<R, E> where R: IntoResponse; especially if R is Response, as the IntoResponse implementation for that would have the error type be Infallible.

Required Methods§

Converts the current type into a response.

Errors

This can error if the conversion into a response fails. This can fail if the current type is a Result, or if e.g. the response fails to serialize.

Implementations on Foreign Types§

Implementors§