pub struct ProblemDetails {
pub problem_type: Option<String>,
pub title: Option<String>,
pub status: Option<u16>,
pub detail: Option<String>,
pub instance: Option<String>,
pub extensions: Map<String, Value>,
}Expand description
The RFC 9457 problem-details members of an error response body, read by name.
Each member is Some only when the body is a JSON object that carries it with the type RFC 9457
gives it: a string for type, title, detail, and instance, and an integer in the HTTP
status range for status. A member that is absent, or present with another type, is None;
the RFC’s own rule for such a member is to ignore it. Nothing here asserts that the server meant
the body as problem details: an object body that is not one still answers with whichever of
these member names it happens to carry. Every other member is an extension member, kept as
JSON in ProblemDetails::extensions.
Fields§
§problem_type: Option<String>The type member: a URI reference naming the problem type. RFC 9457 reads an absent one
as about:blank, which ProblemDetails::problem_type_or_blank applies.
title: Option<String>The title member: a short summary of the problem type.
status: Option<u16>The status member: the status code the origin server generated for this occurrence.
detail: Option<String>The detail member: an explanation specific to this occurrence.
instance: Option<String>The instance member: a URI reference naming this occurrence.
extensions: Map<String, Value>Every member besides the five above, by name: RFC 9457’s extension members, such as a
validation problem’s errors. A standard member present with another type than the RFC
gives it is not an extension, and is in neither place.
Implementations§
Source§impl ProblemDetails
impl ProblemDetails
Sourcepub fn of<T: Serialize + ?Sized>(body: &T) -> Option<Self>
pub fn of<T: Serialize + ?Sized>(body: &T) -> Option<Self>
The members of body as it serializes to JSON: None when it does not serialize to a JSON
object (a string, an array, null, or a failed serialization).
Sourcepub fn from_json(body: &[u8]) -> Option<Self>
pub fn from_json(body: &[u8]) -> Option<Self>
The members of a raw JSON body: None when the bytes are not a JSON object, which includes
a body truncated by the error-body cap.
Sourcepub fn problem_type_or_blank(&self) -> &str
pub fn problem_type_or_blank(&self) -> &str
The problem type, with RFC 9457’s default applied: about:blank when the body carries no
string type member.
Trait Implementations§
Source§impl Clone for ProblemDetails
impl Clone for ProblemDetails
Source§fn clone(&self) -> ProblemDetails
fn clone(&self) -> ProblemDetails
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ProblemDetails
impl Debug for ProblemDetails
Source§impl Default for ProblemDetails
impl Default for ProblemDetails
Source§fn default() -> ProblemDetails
fn default() -> ProblemDetails
impl Eq for ProblemDetails
Source§impl PartialEq for ProblemDetails
impl PartialEq for ProblemDetails
Source§fn eq(&self, other: &ProblemDetails) -> bool
fn eq(&self, other: &ProblemDetails) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ProblemDetails
Auto Trait Implementations§
impl Freeze for ProblemDetails
impl RefUnwindSafe for ProblemDetails
impl Send for ProblemDetails
impl Sync for ProblemDetails
impl Unpin for ProblemDetails
impl UnsafeUnpin for ProblemDetails
impl UnwindSafe for ProblemDetails
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
§unsafe fn consume_handle(handle: Handle) -> Arc<T> ⓘ
unsafe fn consume_handle(handle: Handle) -> Arc<T> ⓘ
Arc<> Read more§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more