Skip to main content

ErrorSetValue

Trait ErrorSetValue 

Source
pub trait ErrorSetValue {
    // Required method
    fn into_response_with(self, status: StatusCode) -> Response;
}
Expand description

Should be implemented for a type to be used as T inside [ApiError<T, _>].

Required Methods§

Source

fn into_response_with(self, status: StatusCode) -> Response

Convert the value into an axum Response with the given status code.

This method must make sure that the response is valid for the given status code, and that it is consistent with the OpenAPI specification generated by [OapiResponseFor].

§Example
use axum_error_sets::{ErrorSetValue};
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()
   }
}

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§