pub struct ProblemDetails {
pub problem_type: String,
pub title: String,
pub status: u16,
pub code: String,
pub detail: Option<String>,
pub instance: Option<String>,
}Expand description
RFC 9457 problem details payload used for server error responses.
The field names intentionally match the wire format so the same type can be reused by future client-side parsing without another translation layer.
Fields§
§problem_type: StringURI identifying the problem type.
title: StringShort, human-readable summary of the problem type.
status: u16HTTP status code. Must match the response status line.
code: StringMachine-readable error code.
detail: Option<String>Per-instance explanation of the error.
instance: Option<String>Request path or URI for the failing resource.
Implementations§
Source§impl ProblemDetails
impl ProblemDetails
Sourcepub fn new(
problem_type: &'static str,
title: &'static str,
status: StatusCode,
code: &'static str,
) -> Self
pub fn new( problem_type: &'static str, title: &'static str, status: StatusCode, code: &'static str, ) -> Self
Create a new problem details payload with the required RFC 9457 fields.
Sourcepub fn with_detail(self, detail: impl Into<String>) -> Self
pub fn with_detail(self, detail: impl Into<String>) -> Self
Attach a problem-specific detail string.
Sourcepub fn with_instance(self, instance: impl Into<String>) -> Self
pub fn with_instance(self, instance: impl Into<String>) -> Self
Attach the request instance path/URI.
Trait Implementations§
Source§impl Clone for ProblemDetails
impl Clone for ProblemDetails
Source§fn clone(&self) -> ProblemDetails
fn clone(&self) -> ProblemDetails
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ProblemDetails
impl Debug for ProblemDetails
Source§impl<'de> Deserialize<'de> for ProblemDetails
impl<'de> Deserialize<'de> for ProblemDetails
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<&ProblemDetails> for ProblemTelemetry
impl From<&ProblemDetails> for ProblemTelemetry
Source§fn from(problem: &ProblemDetails) -> Self
fn from(problem: &ProblemDetails) -> Self
Converts to this type from the input type.
Source§impl PartialEq for ProblemDetails
impl PartialEq for ProblemDetails
Source§impl Serialize for ProblemDetails
impl Serialize for ProblemDetails
impl Eq for ProblemDetails
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.