Struct http_req::response::StatusCode
source · pub struct StatusCode(/* private fields */);
Expand description
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())
Implementations§
source§impl StatusCode
impl StatusCode
sourcepub const fn new(code: u16) -> StatusCode
pub const fn new(code: u16) -> StatusCode
Creates new StatusCode from u16
value.
§Examples
use http_req::response::StatusCode;
const code: StatusCode = StatusCode::new(200);
sourcepub const fn is_info(self) -> bool
pub const fn is_info(self) -> bool
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())
sourcepub const fn is_success(self) -> bool
pub const fn is_success(self) -> bool
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())
sourcepub const fn is_redirect(self) -> bool
pub const fn is_redirect(self) -> bool
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())
sourcepub const fn is_client_err(self) -> bool
pub const fn is_client_err(self) -> bool
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())
sourcepub const fn is_server_err(self) -> bool
pub const fn is_server_err(self) -> bool
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())
Trait Implementations§
source§impl Clone for StatusCode
impl Clone for StatusCode
source§fn clone(&self) -> StatusCode
fn clone(&self) -> StatusCode
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for StatusCode
impl Debug for StatusCode
source§impl Display for StatusCode
impl Display for StatusCode
source§impl From<StatusCode> for u16
impl From<StatusCode> for u16
source§fn from(code: StatusCode) -> Self
fn from(code: StatusCode) -> Self
Converts to this type from the input type.
source§impl From<u16> for StatusCode
impl From<u16> for StatusCode
source§impl FromStr for StatusCode
impl FromStr for StatusCode
source§impl PartialEq for StatusCode
impl PartialEq for StatusCode
source§fn eq(&self, other: &StatusCode) -> bool
fn eq(&self, other: &StatusCode) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Copy for StatusCode
impl StructuralPartialEq for StatusCode
Auto Trait Implementations§
impl Freeze for StatusCode
impl RefUnwindSafe for StatusCode
impl Send for StatusCode
impl Sync for StatusCode
impl Unpin for StatusCode
impl UnwindSafe for StatusCode
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more