pub struct ProblemDetail {
pub type_uri: String,
pub title: String,
pub status: u16,
pub detail: Option<String>,
pub instance: Option<String>,
pub extensions: HashMap<String, Value>,
}Expand description
RFC 7807 Problem Details for HTTP APIs.
Provides a standardized error response format with Content-Type: application/problem+json.
§Example
ⓘ
ProblemDetail::new(404, "Resource Not Found")
.with_detail("Todo with id 42 was not found")
.with_instance("/api/todos/42")
.with_extension("trace_id", "abc123")Fields§
§type_uri: StringA URI reference identifying the problem type (default: “about:blank”).
title: StringA short, human-readable summary of the problem type.
status: u16The HTTP status code.
detail: Option<String>A human-readable explanation specific to this occurrence.
instance: Option<String>A URI reference identifying the specific occurrence.
extensions: HashMap<String, Value>Additional properties (trace_id, transition, axon, etc.).
Implementations§
Source§impl ProblemDetail
impl ProblemDetail
Sourcepub fn new(status: u16, title: impl Into<String>) -> Self
pub fn new(status: u16, title: impl Into<String>) -> Self
Create a new ProblemDetail with status and title.
Sourcepub fn with_type_uri(self, uri: impl Into<String>) -> Self
pub fn with_type_uri(self, uri: impl Into<String>) -> Self
Set the problem type URI.
Sourcepub fn with_detail(self, detail: impl Into<String>) -> Self
pub fn with_detail(self, detail: impl Into<String>) -> Self
Set the detail message.
Sourcepub fn with_instance(self, instance: impl Into<String>) -> Self
pub fn with_instance(self, instance: impl Into<String>) -> Self
Set the instance URI.
Trait Implementations§
Source§impl Clone for ProblemDetail
impl Clone for ProblemDetail
Source§fn clone(&self) -> ProblemDetail
fn clone(&self) -> ProblemDetail
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 ProblemDetail
impl Debug for ProblemDetail
Source§impl<'de> Deserialize<'de> for ProblemDetail
impl<'de> Deserialize<'de> for ProblemDetail
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 IntoResponse for ProblemDetail
impl IntoResponse for ProblemDetail
fn into_response(self) -> HttpResponse
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
Mutably borrows from an owned value. Read more