pub struct XmlProblemDetails<Ext = ()>(/* private fields */);
Expand description

ProblemDetails that is encoded to XML when used with web framework integrations.

Example

use http::StatusCode;
use problem_details::{XmlProblemDetails, ProblemDetails};

async fn handler() -> XmlProblemDetails {
    ProblemDetails::from_status_code(StatusCode::IM_A_TEAPOT)
        .with_detail("short and stout")
        .into()
}

Implementations§

source§

impl<Ext> XmlProblemDetails<Ext>

source

pub const CONTENT_TYPE: &'static str = "application/problem+xml"

The HTTP content type for a xml problem details.

source§

impl<Ext> XmlProblemDetails<Ext>
where Ext: Serialize,

source

pub fn to_body_string(&self) -> Result<String, XmlError>

Write this problem details to an XML string suitable for a response body.

Trait Implementations§

source§

impl<Ext: Clone> Clone for XmlProblemDetails<Ext>

source§

fn clone(&self) -> XmlProblemDetails<Ext>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<Ext: Debug> Debug for XmlProblemDetails<Ext>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<Ext: Default> Default for XmlProblemDetails<Ext>

source§

fn default() -> XmlProblemDetails<Ext>

Returns the “default value” for a type. Read more
source§

impl<Ext> Display for XmlProblemDetails<Ext>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<Ext> Error for XmlProblemDetails<Ext>
where Ext: Debug,

1.30.0 · source§

fn source(&self) -> Option<&(dyn Error + 'static)>

The lower-level source of this error, if any. Read more
1.0.0 · source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type based access to context intended for error reports. Read more
source§

impl<Ext> From<ProblemDetails<Ext>> for XmlProblemDetails<Ext>

source§

fn from(value: ProblemDetails<Ext>) -> Self

Converts to this type from the input type.
source§

impl<Ext> From<XmlProblemDetails<Ext>> for ProblemDetails<Ext>

source§

fn from(value: XmlProblemDetails<Ext>) -> Self

Converts to this type from the input type.
source§

impl<Ext> IntoResponse for XmlProblemDetails<Ext>
where Ext: Serialize,

source§

fn into_response(self) -> Response

Create a response.
source§

impl<Ext> IntoResponse for XmlProblemDetails<Ext>
where Ext: Serialize + Send,

source§

fn into_response(self) -> Response

Consume itself and return Response.
source§

fn with_header<K, V>(self, key: K, value: V) -> WithHeader<Self>
where K: TryInto<HeaderName>, V: TryInto<HeaderValue>, Self: Sized,

Wrap an impl IntoResponse to add a header. Read more
source§

fn with_content_type<V>(self, content_type: V) -> WithContentType<Self>
where V: TryInto<HeaderValue>, Self: Sized,

Wrap an impl IntoResponse to with a new content type. Read more
source§

fn with_status(self, status: StatusCode) -> WithStatus<Self>
where Self: Sized,

Wrap an impl IntoResponse to set a status code. Read more
source§

fn with_body(self, body: impl Into<Body>) -> WithBody<Self>
where Self: Sized,

Wrap an impl IntoResponse to set a body. Read more
source§

impl<Ext: PartialEq> PartialEq for XmlProblemDetails<Ext>

source§

fn eq(&self, other: &XmlProblemDetails<Ext>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<Ext> ResponseError for XmlProblemDetails<Ext>
where Ext: Serialize + Clone + Send,

source§

fn status(&self) -> StatusCode

The status code of this error.
source§

fn as_response(&self) -> Response

Convert this error to a HTTP response.
source§

impl<Ext: Eq> Eq for XmlProblemDetails<Ext>

source§

impl<Ext> StructuralEq for XmlProblemDetails<Ext>

source§

impl<Ext> StructuralPartialEq for XmlProblemDetails<Ext>

Auto Trait Implementations§

§

impl<Ext> RefUnwindSafe for XmlProblemDetails<Ext>
where Ext: RefUnwindSafe,

§

impl<Ext> Send for XmlProblemDetails<Ext>
where Ext: Send,

§

impl<Ext> Sync for XmlProblemDetails<Ext>
where Ext: Sync,

§

impl<Ext> Unpin for XmlProblemDetails<Ext>
where Ext: Unpin,

§

impl<Ext> UnwindSafe for XmlProblemDetails<Ext>
where Ext: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
source§

impl<T, S> Handler<IntoResponseHandler, S> for T
where T: IntoResponse + Clone + Send + 'static,

§

type Future = Ready<Response<Body>>

The type of future calling this handler returns.
source§

fn call( self, _req: Request<Body>, _state: S ) -> <T as Handler<IntoResponseHandler, S>>::Future

Call the handler with the given request.
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>>,

Apply a [tower::Layer] to the handler. Read more
source§

fn with_state(self, state: S) -> HandlerService<Self, T, S>

Convert the handler into a [Service] by providing the state
source§

impl<H, T> HandlerWithoutStateExt<T> for H
where H: Handler<T, ()>,

source§

fn into_service(self) -> HandlerService<H, T, ()>

Convert the handler into a [Service] and no state.
source§

fn into_make_service(self) -> IntoMakeService<HandlerService<H, T, ()>>

Convert the handler into a MakeService and no state. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoResult<T> for T
where T: IntoResponse,

source§

fn into_result(self) -> Result<T, Error>

Consumes this value returns a poem::Result<T>.
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more