Skip to main content

IntoResponse

Trait IntoResponse 

Source
pub trait IntoResponse {
    // Required methods
    fn openapi(registry: &mut Registry) -> Responses;
    fn into_response(self) -> Response;
}
Expand description

A type that is convertible to an HTTP response with OpenAPI description.

Most notably, this trait is implemented for

  • T: ToSchema + SchemaSerialize, returning a 200 Ok response with Content-Type: application/json
  • Result<T, E> with T: IntoResponse and E: IntoResponse
  • The new-type structs in this module named after status codes (e.g. Created)

Required Methods§

Source

fn openapi(registry: &mut Registry) -> Responses

Describes the responses generated via the into_response function.

Source

fn into_response(self) -> Response

Converts this value into an axum 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.

Implementations on Foreign Types§

Source§

impl IntoResponse for Infallible

Source§

impl<T: IntoResponse, E: IntoResponse> IntoResponse for Result<T, E>

Implementors§