Struct net_traits::http_status::HttpStatus
source · pub struct HttpStatus {
code: u16,
message: Vec<u8>,
}
Expand description
A representation of a HTTP Status Code and Message that can be used for DOM Response objects and other cases. These objects are immutable once created.
Fields§
§code: u16
§message: Vec<u8>
Implementations§
source§impl HttpStatus
impl HttpStatus
sourcepub fn new(code: StatusCode, message: Vec<u8>) -> Self
pub fn new(code: StatusCode, message: Vec<u8>) -> Self
Creates a new HttpStatus for a valid status code.
sourcepub fn new_raw(code: u16, message: Vec<u8>) -> Self
pub fn new_raw(code: u16, message: Vec<u8>) -> Self
Creates a new HttpStatus from a raw status code, but will panic if the code is not in the 100 to 599 valid range.
sourcepub fn code(&self) -> StatusCode
pub fn code(&self) -> StatusCode
Returns the StatusCode for non-error cases, panics otherwise.
sourcepub fn try_code(&self) -> Option<StatusCode>
pub fn try_code(&self) -> Option<StatusCode>
Returns the StatusCode if not an error instance, or None otherwise.
sourcepub fn raw_code(&self) -> u16
pub fn raw_code(&self) -> u16
Returns the u16 representation of the access code. This is usable both for valid HTTP status codes and in the error case.
sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Helper that relays is_success() from the underlying code.
sourcepub fn in_range<T: RangeBounds<u16>>(&self, range: T) -> bool
pub fn in_range<T: RangeBounds<u16>>(&self, range: T) -> bool
Returns true if this status is in the given range. Always return false for error statuses.
Trait Implementations§
source§impl Clone for HttpStatus
impl Clone for HttpStatus
source§fn clone(&self) -> HttpStatus
fn clone(&self) -> HttpStatus
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 HttpStatus
impl Debug for HttpStatus
source§impl Default for HttpStatus
impl Default for HttpStatus
source§impl<'de> Deserialize<'de> for HttpStatus
impl<'de> Deserialize<'de> for HttpStatus
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl From<StatusCode> for HttpStatus
impl From<StatusCode> for HttpStatus
source§fn from(code: StatusCode) -> Self
fn from(code: StatusCode) -> Self
Converts to this type from the input type.
source§impl MallocSizeOf for HttpStatus
impl MallocSizeOf for HttpStatus
source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
Measure the heap usage of all descendant heap-allocated structures, but
not the space taken up by the value itself.
source§impl PartialEq<StatusCode> for HttpStatus
impl PartialEq<StatusCode> for HttpStatus
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 ==
.source§impl PartialEq for HttpStatus
impl PartialEq for HttpStatus
source§fn eq(&self, other: &HttpStatus) -> bool
fn eq(&self, other: &HttpStatus) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl Serialize for HttpStatus
impl Serialize for HttpStatus
impl StructuralPartialEq for HttpStatus
Auto Trait Implementations§
impl Freeze for HttpStatus
impl RefUnwindSafe for HttpStatus
impl Send for HttpStatus
impl Sync for HttpStatus
impl Unpin for HttpStatus
impl UnwindSafe for HttpStatus
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
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> MaybeBoxed<Box<T>> for T
impl<T> MaybeBoxed<Box<T>> for T
source§fn maybe_boxed(self) -> Box<T>
fn maybe_boxed(self) -> Box<T>
Convert
source§impl<T> MaybeBoxed<T> for T
impl<T> MaybeBoxed<T> for T
source§fn maybe_boxed(self) -> T
fn maybe_boxed(self) -> T
Convert
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian()
.