pub trait AideErrorSetValue: ErrorSetValue {
type Inner;
// Required method
fn inferred_response_for(
ctx: &mut GenContext,
operation: &mut Operation,
status: StatusCode,
) -> Response;
}Expand description
Should be implemented for a type to be used as T inside [ApiError<T, _>], for
usage with aide.
Required Associated Types§
Required Methods§
Sourcefn inferred_response_for(
ctx: &mut GenContext,
operation: &mut Operation,
status: StatusCode,
) -> Response
fn inferred_response_for( ctx: &mut GenContext, operation: &mut Operation, status: StatusCode, ) -> Response
See aide::OperationOutput::inferred_responses.
§Example
use axum_error_sets::{ErrorSetValue, AideErrorSetValue};
use axum::response::{IntoResponse, Response};
use http::StatusCode;
struct MyErrorValue(String);
impl ErrorSetValue for MyErrorValue {
fn into_response_with(self, status: StatusCode) -> Response {
(status, self.0).into_response()
}
}
impl AideErrorSetValue for MyErrorValue {
type Inner = String;
fn inferred_response_for(
_ctx: &mut aide::generate::GenContext,
_operation: &mut aide::openapi::Operation,
status: StatusCode,
) -> aide::openapi::Response {
aide::openapi::Response {
description: format!("Error: {}", status),
..Default::default()
}
}
}Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".