[][src]Struct nebula_status::Status

pub struct Status<T = Empty> where
    T: StatusData
{ /* fields omitted */ }

An HTTP status code bundled with associated data.

Code that creates a new instance of Status should set any related response headers before returning it.

Implementations

impl Status[src]

pub fn new(code: StatusCode) -> Status<Empty>[src]

Create a new Status without any associated data. This will be converted to the specified status code with associated headers and no body.

pub fn with_message(code: StatusCode, msg: String) -> Status<String>[src]

Create a new Status with associated data of type String. Useful for returning basic error messages.

pub fn with_data<T: StatusData>(code: StatusCode, data: T) -> Status<T>[src]

Create a new Status with associated arbitrary data. Useful for returning a struct that can be serialized into e.g. JSON.

impl<T: StatusData> Status<T>[src]

pub fn code(&self) -> &StatusCode[src]

Gain a reference to this Status' status code.

pub fn message(&self) -> Option<&str>[src]

Attempts to parse the data contained in this Status as a &str.

The Content-Type header is used to help determine if the data is meant to be parsed as text or not.

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

Returns a reference to the contained data.

pub fn bytes(&self) -> &[u8][src]

pub fn headers(&self) -> &HeaderMap<HeaderValue>[src]

Gain an immutable view into the headers map.

pub fn headers_mut(&mut self) -> &mut HeaderMap<HeaderValue>[src]

Gain a mutable reference to the headers map.

Trait Implementations

impl<T: Clone> Clone for Status<T> where
    T: StatusData
[src]

impl<T: Debug> Debug for Status<T> where
    T: StatusData
[src]

impl<T: StatusData> Display for Status<T>[src]

impl<T: Eq> Eq for Status<T> where
    T: StatusData
[src]

impl<T: StatusData> Error for Status<T>[src]

impl<T: StatusData> From<Status<T>> for Result<Status<T>, Status<T>>[src]

impl<T: PartialEq> PartialEq<Status<T>> for Status<T> where
    T: StatusData
[src]

impl<T> StructuralEq for Status<T> where
    T: StatusData
[src]

impl<T> StructuralPartialEq for Status<T> where
    T: StatusData
[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Status<T> where
    T: RefUnwindSafe

impl<T> Send for Status<T>

impl<T> Sync for Status<T>

impl<T> Unpin for Status<T> where
    T: Unpin

impl<T> UnwindSafe for Status<T> where
    T: UnwindSafe

Blanket Implementations

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

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> StatusInnerData for T where
    T: 'static + Clone + Send + Sync + Debug
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.