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>) -> HttpStatus
pub fn new(code: StatusCode, message: Vec<u8>) -> HttpStatus
Creates a new HttpStatus for a valid status code.
Sourcepub fn new_raw(code: u16, message: Vec<u8>) -> HttpStatus
pub fn new_raw(code: u16, message: Vec<u8>) -> HttpStatus
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 new_error() -> HttpStatus
pub fn new_error() -> HttpStatus
Creates an instance that represents a Response.error() instance.
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>(&self, range: T) -> boolwhere
T: RangeBounds<u16>,
pub fn in_range<T>(&self, range: T) -> boolwhere
T: RangeBounds<u16>,
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
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for HttpStatus
impl Debug for HttpStatus
Source§impl Default for HttpStatus
impl Default for HttpStatus
Source§fn default() -> HttpStatus
fn default() -> HttpStatus
The default implementation creates a “200 OK” response.
Source§impl<'de> Deserialize<'de> for HttpStatus
impl<'de> Deserialize<'de> for HttpStatus
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<HttpStatus, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<HttpStatus, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl From<StatusCode> for HttpStatus
impl From<StatusCode> for HttpStatus
Source§fn from(code: StatusCode) -> HttpStatus
fn from(code: StatusCode) -> HttpStatus
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
Source§impl PartialEq<StatusCode> for HttpStatus
impl PartialEq<StatusCode> for HttpStatus
Source§impl PartialEq for HttpStatus
impl PartialEq for HttpStatus
Source§impl Serialize for HttpStatus
impl Serialize for HttpStatus
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Filterable for T
impl<T> Filterable for T
Source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>
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>
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>
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 more