pub trait ToResponses {
// Required method
fn to_responses(components: &mut Components) -> Responses;
}Expand description
This trait is implemented to document a type (like an enum) which can represent multiple responses, to be used in operation.
§Examples
use std::collections::BTreeMap;
use salvo_oapi::{Components, RefOr, Response, Responses, ToResponses};
enum MyResponse {
Ok,
NotFound,
}
impl ToResponses for MyResponse {
fn to_responses(_components: &mut Components) -> Responses {
Responses::new()
.response("200", Response::new("Ok"))
.response("404", Response::new("Not Found"))
}
}Required Methods§
Sourcefn to_responses(components: &mut Components) -> Responses
fn to_responses(components: &mut Components) -> Responses
Returns an ordered map of response codes to responses.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl ToResponses for Error
impl ToResponses for Error
fn to_responses(components: &mut Components) -> Responses
Source§impl ToResponses for StatusError
impl ToResponses for StatusError
fn to_responses(components: &mut Components) -> Responses
Source§impl<C> ToResponses for Json<C>where
C: ToSchema,
impl<C> ToResponses for Json<C>where
C: ToSchema,
fn to_responses(components: &mut Components) -> Responses
Source§impl<Extensions> ToResponses for Problem<Extensions>where
Extensions: ToSchema + 'static,
Available on crate feature rfc9457 only.
impl<Extensions> ToResponses for Problem<Extensions>where
Extensions: ToSchema + 'static,
Available on crate feature
rfc9457 only.