MapErr

Struct MapErr 

Source
pub struct MapErr<W, F, T>(/* private fields */);
Expand description

Changes the error type of a web request and response.

Implementations§

Source§

impl<W, F, T> MapErr<W, F, T>

Source

pub fn request(request: W, f: F) -> Self
where W: WebRequest, F: FnMut(W::Error) -> T,

Map all errors in request methods using the given function.

Source

pub fn response(response: W, f: F) -> Self
where W: WebResponse, F: FnMut(W::Error) -> T,

Map all errors in response methods using the given function.

Source

pub fn into_inner(self) -> W

Recover original response or request.

Trait Implementations§

Source§

impl<W: WebRequest, F, T> WebRequest for MapErr<W, F, T>
where F: FnMut(W::Error) -> T,

Source§

type Error = T

The error generated from access of malformed or invalid requests.
Source§

type Response = MapErr<<W as WebRequest>::Response, F, T>

The corresponding type of Responses returned from this module.
Source§

fn query( &mut self, ) -> Result<Cow<'_, dyn QueryParameter + 'static>, Self::Error>

Retrieve a parsed version of the url query. Read more
Source§

fn urlbody( &mut self, ) -> Result<Cow<'_, dyn QueryParameter + 'static>, Self::Error>

Retrieve the parsed application/x-form-urlencoded body of the request. Read more
Source§

fn authheader(&mut self) -> Result<Option<Cow<'_, str>>, Self::Error>

Contents of the authorization header or none if none exists. An Err value indicates a malformed header or request.
Source§

impl<W: WebResponse, F, T> WebResponse for MapErr<W, F, T>
where F: FnMut(W::Error) -> T,

Source§

fn redirect(&mut self, url: Url) -> Result<(), Self::Error>

A response which will redirect the user-agent to which the response is issued.

Source§

fn client_error(&mut self) -> Result<(), Self::Error>

Set the response status to 400.

Source§

fn unauthorized(&mut self, header_value: &str) -> Result<(), Self::Error>

Set the response status to 401 and add a WWW-Authenticate header.

Source§

fn body_text(&mut self, text: &str) -> Result<(), Self::Error>

A pure text response with no special media type set.

Source§

fn body_json(&mut self, data: &str) -> Result<(), Self::Error>

Json repsonse data, with media type `aplication/json.

Source§

type Error = T

The error generated when trying to construct an unhandled or invalid response.
Source§

fn ok(&mut self) -> Result<(), Self::Error>

Set the response status to 200.

Auto Trait Implementations§

§

impl<W, F, T> Freeze for MapErr<W, F, T>
where W: Freeze, F: Freeze,

§

impl<W, F, T> RefUnwindSafe for MapErr<W, F, T>

§

impl<W, F, T> Send for MapErr<W, F, T>
where W: Send, F: Send, T: Send,

§

impl<W, F, T> Sync for MapErr<W, F, T>
where W: Sync, F: Sync, T: Sync,

§

impl<W, F, T> Unpin for MapErr<W, F, T>
where W: Unpin, F: Unpin, T: Unpin,

§

impl<W, F, T> UnwindSafe for MapErr<W, F, T>
where W: UnwindSafe, F: UnwindSafe, T: 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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V