pub struct Problem {
pub type_uri: String,
pub title: String,
pub status: u16,
pub detail: Option<String>,
pub instance: Option<String>,
pub extensions: Map<String, Value>,
}Expand description
RFC 9457 problem details response.
Fields§
§type_uri: String§title: String§status: u16§detail: Option<String>§instance: Option<String>§extensions: Map<String, Value>Implementations§
Source§impl Problem
impl Problem
Sourcepub fn new(
type_uri: impl Into<String>,
title: impl Into<String>,
status: u16,
) -> Self
pub fn new( type_uri: impl Into<String>, title: impl Into<String>, status: u16, ) -> Self
Create a problem with a fully-qualified type_uri.
Sourcepub fn detail(self, detail: impl Into<String>) -> Self
pub fn detail(self, detail: impl Into<String>) -> Self
Human-readable explanation of the specific occurrence.
Sourcepub fn instance(self, instance: impl Into<String>) -> Self
pub fn instance(self, instance: impl Into<String>) -> Self
URI reference that identifies the specific occurrence.
Sourcepub fn extend(self, key: impl Into<String>, value: impl Into<Value>) -> Self
pub fn extend(self, key: impl Into<String>, value: impl Into<Value>) -> Self
Attach a custom extension member (serialisable value).
Sourcepub fn bad_request(detail: impl Into<String>) -> Self
pub fn bad_request(detail: impl Into<String>) -> Self
400 Bad Request.
401 Unauthorized.
Sourcepub fn unprocessable(detail: impl Into<String>) -> Self
pub fn unprocessable(detail: impl Into<String>) -> Self
422 Unprocessable Entity.
Sourcepub fn too_many_requests(detail: impl Into<String>) -> Self
pub fn too_many_requests(detail: impl Into<String>) -> Self
429 Too Many Requests.
503 Service Unavailable.
Sourcepub fn from_validation(errors: HashMap<String, Vec<String>>) -> Self
pub fn from_validation(errors: HashMap<String, Vec<String>>) -> Self
Build an unprocessable-entity problem from a map of field → errors.
Sourcepub fn to_json_bytes(&self) -> Vec<u8> ⓘ
pub fn to_json_bytes(&self) -> Vec<u8> ⓘ
Serialize to a JSON byte vec.
On serialization failure, logs the error and returns b"{}" as a
minimal RFC 9457-compliant fallback.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Problem
impl RefUnwindSafe for Problem
impl Send for Problem
impl Sync for Problem
impl Unpin for Problem
impl UnsafeUnpin for Problem
impl UnwindSafe for Problem
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<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
Converts
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>
Converts
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