ToResponse

Trait ToResponse 

Source
pub trait ToResponse {
    // Required method
    fn to_response(components: &mut Components) -> RefOr<Response>;
}
Expand description

This trait is implemented to document a type which represents a single response which can be referenced or reused as a component in multiple operations.

ToResponse trait can also be derived with #[derive(ToResponse)].

§Examples

use salvo_oapi::{RefOr, Response, Components, ToResponse};

struct MyResponse;
impl ToResponse for MyResponse {
    fn to_response(_components: &mut Components) -> RefOr<Response> {
        Response::new("My Response").into()
    }
}

Required Methods§

Source

fn to_response(components: &mut Components) -> RefOr<Response>

Returns a tuple of response component name (to be referenced) to a 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<C> ToResponse for Json<C>
where C: ToSchema,

Source§

fn to_response(components: &mut Components) -> RefOr<Response>

Implementors§