Struct rocket::response::Debug[][src]

pub struct Debug<E>(pub E);
Expand description

Debug prints the internal value before responding with a 500 error.

This value exists primarily to allow handler return types that would not otherwise implement Responder. It is typically used in conjunction with Result<T, E> where E implements Debug but not Responder.


Because of the generic From<E> implementation for Debug<E>, conversions from Result<T, E> to Result<T, Debug<E>> through ? occur automatically:

use std::io::{self, Read};

use rocket::Data;
use rocket::response::Debug;

#[post("/", format = "plain", data = "<data>")]
fn post(data: Data) -> Result<String, Debug<io::Error>> {
    let mut name = String::with_capacity(32); name)?;

It is also possible to map the error directly to Debug via Result::map_err():

use std::string::FromUtf8Error;

use rocket::response::Debug;

fn rand_str() -> Result<String, Debug<FromUtf8Error>> {
    let bytes: Vec<u8> = random_bytes();

Trait Implementations

impl<E: Debug> Debug for Debug<E>[src]

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

Formats the value using the given formatter. Read more

impl<E> From<E> for Debug<E>[src]

fn from(e: E) -> Self[src]

Performs the conversion.

impl<'r, E: Debug> Responder<'r> for Debug<E>[src]

fn respond_to(self, _: &Request<'_>) -> Result<'r>[src]

Returns Ok if a Response could be generated successfully. Otherwise, returns an Err with a failing Status. Read more

Auto Trait Implementations

impl<E> RefUnwindSafe for Debug<E> where
    E: RefUnwindSafe

impl<E> Send for Debug<E> where
    E: Send

impl<E> Sync for Debug<E> where
    E: Sync

impl<E> Unpin for Debug<E> where
    E: Unpin

impl<E> UnwindSafe for Debug<E> where
    E: UnwindSafe

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T, I> AsResult<T, I> for T where
    I: Input

pub fn as_result(self) -> Result<T, ParseErr<I>>[src]

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<!> for T[src]

pub fn from(t: !) -> T[src]

Performs the conversion.

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> IntoCollection<T> for T

pub fn into_collection<A>(self) -> SmallVec<A> where
    A: Array<Item = T>, 

Converts self into a collection.

pub fn mapped<U, F, A>(self, f: F) -> SmallVec<A> where
    F: FnMut(T) -> U,
    A: Array<Item = U>, 

impl<T> Same<T> for T

type Output = T

Should always be Self

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

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

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.

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

Performs the conversion.

impl<T> Typeable for T where
    T: Any

fn get_type(&self) -> TypeId

Get the TypeId of this object.

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

pub fn vzip(self) -> V