[][src]Struct http_req::response::StatusCode

pub struct StatusCode(_);

Code sent by a server in response to a client's request.

Example

use http_req::response::StatusCode;

const code: StatusCode = StatusCode::new(200);
assert!(code.is_success())

Methods

impl StatusCode[src]

pub const fn new(code: u16) -> StatusCode[src]

Creates new StatusCode from u16 value.

Examples

use http_req::response::StatusCode;

const code: StatusCode = StatusCode::new(200);

pub fn is_info(self) -> bool[src]

Checks if this StatusCode is within 100-199, which indicates that it's Informational.

Examples

use http_req::response::StatusCode;

const code: StatusCode = StatusCode::new(101);
assert!(code.is_info())

pub fn is_success(self) -> bool[src]

Checks if this StatusCode is within 200-299, which indicates that it's Successful.

Examples

use http_req::response::StatusCode;

const code: StatusCode = StatusCode::new(204);
assert!(code.is_success())

pub fn is_redirect(self) -> bool[src]

Checks if this StatusCode is within 300-399, which indicates that it's Redirection.

Examples

use http_req::response::StatusCode;

const code: StatusCode = StatusCode::new(301);
assert!(code.is_redirect())

pub fn is_client_err(self) -> bool[src]

Checks if this StatusCode is within 400-499, which indicates that it's Client Error.

Examples

use http_req::response::StatusCode;

const code: StatusCode = StatusCode::new(400);
assert!(code.is_client_err())

pub fn is_server_err(self) -> bool[src]

Checks if this StatusCode is within 500-599, which indicates that it's Server Error.

Examples

use http_req::response::StatusCode;

const code: StatusCode = StatusCode::new(503);
assert!(code.is_server_err())

pub fn is<F: FnOnce(u16) -> bool>(self, f: F) -> bool[src]

Checks this StatusCode using closure f

Examples

use http_req::response::StatusCode;

const code: StatusCode = StatusCode::new(203);
assert!(code.is(|i| i > 199 && i < 250))

pub fn reason(self) -> Option<&'static str>[src]

Returns Reason-Phrase corresponding to this StatusCode

Examples

use http_req::response::StatusCode;

const code: StatusCode = StatusCode::new(200);
assert_eq!(code.reason(), Some("OK"))

Trait Implementations

impl Clone for StatusCode[src]

impl Copy for StatusCode[src]

impl Debug for StatusCode[src]

impl Display for StatusCode[src]

impl From<StatusCode> for u16[src]

impl From<u16> for StatusCode[src]

impl FromStr for StatusCode[src]

type Err = ParseErr

The associated error which can be returned from parsing.

impl PartialEq<StatusCode> for StatusCode[src]

impl StructuralPartialEq for StatusCode[src]

Auto Trait Implementations

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