pub struct ProblemDetail {
pub type_uri: String,
pub title: String,
pub status: u16,
pub detail: Option<String>,
pub instance: Option<String>,
pub error_code: Option<&'static str>,
}Expand description
RFC 7807 Problem Details JSON body.
Fields§
§type_uri: StringURI reference identifying the problem type.
title: StringShort human-readable summary.
status: u16HTTP status code.
detail: Option<String>Human-readable explanation specific to this occurrence.
instance: Option<String>URI reference identifying the specific occurrence.
error_code: Option<&'static str>Stable machine-readable error code (e.g. "invalid_threshold")
for clients that need to branch on the specific failure
without parsing the human-readable detail. Omitted from the
wire when unset so existing endpoints stay byte-identical.
Codes are static identifiers — &'static str keeps the struct
small enough that handlers returning Result<_, ProblemDetail>
stay under clippy’s result_large_err threshold.
Implementations§
Source§impl ProblemDetail
impl ProblemDetail
Sourcepub fn from_status(status: StatusCode) -> Self
pub fn from_status(status: StatusCode) -> Self
Create a ProblemDetail from an HTTP status code.
Sourcepub fn with_detail(self, detail: impl Into<String>) -> Self
pub fn with_detail(self, detail: impl Into<String>) -> Self
Attach a human-readable detail message.
Sourcepub fn with_instance(self, instance: impl Into<String>) -> Self
pub fn with_instance(self, instance: impl Into<String>) -> Self
Attach the request URI as the instance identifier.
Sourcepub fn with_error_code(self, code: &'static str) -> Self
pub fn with_error_code(self, code: &'static str) -> Self
Attach a stable machine-readable error code.
Trait Implementations§
Source§impl Clone for ProblemDetail
impl Clone for ProblemDetail
Source§fn clone(&self) -> ProblemDetail
fn clone(&self) -> ProblemDetail
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl ComposeSchema for ProblemDetail
impl ComposeSchema for ProblemDetail
Source§impl Debug for ProblemDetail
impl Debug for ProblemDetail
Source§impl IntoResponse for ProblemDetail
impl IntoResponse for ProblemDetail
Source§fn into_response(self) -> Response
fn into_response(self) -> Response
Source§impl Serialize for ProblemDetail
impl Serialize for ProblemDetail
Auto Trait Implementations§
impl Freeze for ProblemDetail
impl RefUnwindSafe for ProblemDetail
impl Send for ProblemDetail
impl Sync for ProblemDetail
impl Unpin for ProblemDetail
impl UnsafeUnpin for ProblemDetail
impl UnwindSafe for ProblemDetail
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, S> Handler<IntoResponseHandler, S> for T
impl<T, S> Handler<IntoResponseHandler, S> for T
Source§fn call(
self,
_req: Request<Body>,
_state: S,
) -> <T as Handler<IntoResponseHandler, S>>::Future
fn call( self, _req: Request<Body>, _state: S, ) -> <T as Handler<IntoResponseHandler, S>>::Future
Source§fn layer<L>(self, layer: L) -> Layered<L, Self, T, S>where
L: Layer<HandlerService<Self, T, S>> + Clone,
<L as Layer<HandlerService<Self, T, S>>>::Service: Service<Request<Body>>,
fn layer<L>(self, layer: L) -> Layered<L, Self, T, S>where
L: Layer<HandlerService<Self, T, S>> + Clone,
<L as Layer<HandlerService<Self, T, S>>>::Service: Service<Request<Body>>,
tower::Layer to the handler. Read moreSource§fn with_state(self, state: S) -> HandlerService<Self, T, S>
fn with_state(self, state: S) -> HandlerService<Self, T, S>
Service by providing the stateSource§impl<H, T> HandlerWithoutStateExt<T> for H
impl<H, T> HandlerWithoutStateExt<T> for H
Source§fn into_service(self) -> HandlerService<H, T, ()>
fn into_service(self) -> HandlerService<H, T, ()>
Service and no state.Source§fn into_make_service(self) -> IntoMakeService<HandlerService<H, T, ()>>
fn into_make_service(self) -> IntoMakeService<HandlerService<H, T, ()>>
MakeService and no state. Read moreSource§fn into_make_service_with_connect_info<C>(
self,
) -> IntoMakeServiceWithConnectInfo<HandlerService<H, T, ()>, C>
fn into_make_service_with_connect_info<C>( self, ) -> IntoMakeServiceWithConnectInfo<HandlerService<H, T, ()>, C>
MakeService which stores information
about the incoming connection and has no state. Read more