Trait salvo::prelude::ToResponse
source · pub trait ToResponse {
// Required method
fn to_response(components: &mut Components) -> RefOr<Response>;
}
Available on crate feature
oapi
only.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§
sourcefn to_response(components: &mut Components) -> RefOr<Response>
fn to_response(components: &mut Components) -> RefOr<Response>
Returns a tuple of response component name (to be referenced) to a response.
Object Safety§
This trait is not object safe.