Struct tastyworks::request::StatusCode [−][src]
pub struct StatusCode(_);
Expand description
An HTTP status code (status-code
in RFC 7230 et al.).
Constants are provided for known status codes, including those in the IANA HTTP Status Code Registry.
Status code values in the range 100-999 (inclusive) are supported by this
type. Values in the range 100-599 are semantically classified by the most
significant digit. See StatusCode::is_success
, etc. Values above 599
are unclassified but allowed for legacy compatibility, though their use is
discouraged. Applications may interpret such values as protocol errors.
Examples
use http::StatusCode; assert_eq!(StatusCode::from_u16(200).unwrap(), StatusCode::OK); assert_eq!(StatusCode::NOT_FOUND.as_u16(), 404); assert!(StatusCode::OK.is_success());
Implementations
impl StatusCode
[src]
impl StatusCode
[src]pub fn from_u16(src: u16) -> Result<StatusCode, InvalidStatusCode>
[src]
pub fn from_u16(src: u16) -> Result<StatusCode, InvalidStatusCode>
[src]Converts a u16 to a status code.
The function validates the correctness of the supplied u16. It must be greater or equal to 100 and less than 1000.
Example
use http::StatusCode; let ok = StatusCode::from_u16(200).unwrap(); assert_eq!(ok, StatusCode::OK); let err = StatusCode::from_u16(99); assert!(err.is_err());
pub fn from_bytes(src: &[u8]) -> Result<StatusCode, InvalidStatusCode>
[src]
pub fn from_bytes(src: &[u8]) -> Result<StatusCode, InvalidStatusCode>
[src]Converts a &u8 to a status code
pub fn as_u16(&self) -> u16
[src]
pub fn as_u16(&self) -> u16
[src]Returns the u16
corresponding to this StatusCode
.
Note
This is the same as the From<StatusCode>
implementation, but
included as an inherent method because that implementation doesn’t
appear in rustdocs, as well as a way to force the type instead of
relying on inference.
Example
let status = http::StatusCode::OK; assert_eq!(status.as_u16(), 200);
pub fn as_str(&self) -> &str
[src]
pub fn as_str(&self) -> &str
[src]Returns a &str representation of the StatusCode
The return value only includes a numerical representation of the status code. The canonical reason is not included.
Example
let status = http::StatusCode::OK; assert_eq!(status.as_str(), "200");
pub fn canonical_reason(&self) -> Option<&'static str>
[src]
pub fn canonical_reason(&self) -> Option<&'static str>
[src]Get the standardised reason-phrase
for this status code.
This is mostly here for servers writing responses, but could potentially have application at other times.
The reason phrase is defined as being exclusively for human readers. You should avoid deriving any meaning from it at all costs.
Bear in mind also that in HTTP/2.0 and HTTP/3.0 the reason phrase is abolished from transmission, and so this canonical reason phrase really is the only reason phrase you’ll find.
Example
let status = http::StatusCode::OK; assert_eq!(status.canonical_reason(), Some("OK"));
pub fn is_informational(&self) -> bool
[src]
pub fn is_informational(&self) -> bool
[src]Check if status is within 100-199.
pub fn is_success(&self) -> bool
[src]
pub fn is_success(&self) -> bool
[src]Check if status is within 200-299.
pub fn is_redirection(&self) -> bool
[src]
pub fn is_redirection(&self) -> bool
[src]Check if status is within 300-399.
pub fn is_client_error(&self) -> bool
[src]
pub fn is_client_error(&self) -> bool
[src]Check if status is within 400-499.
pub fn is_server_error(&self) -> bool
[src]
pub fn is_server_error(&self) -> bool
[src]Check if status is within 500-599.
impl StatusCode
[src]
impl StatusCode
[src]pub const CONTINUE: StatusCode
[src]
pub const CONTINUE: StatusCode
[src]100 Continue [RFC7231, Section 6.2.1]
pub const SWITCHING_PROTOCOLS: StatusCode
[src]
pub const SWITCHING_PROTOCOLS: StatusCode
[src]101 Switching Protocols [RFC7231, Section 6.2.2]
pub const PROCESSING: StatusCode
[src]
pub const PROCESSING: StatusCode
[src]102 Processing [RFC2518]
pub const OK: StatusCode
[src]
pub const OK: StatusCode
[src]200 OK [RFC7231, Section 6.3.1]
pub const CREATED: StatusCode
[src]
pub const CREATED: StatusCode
[src]201 Created [RFC7231, Section 6.3.2]
pub const ACCEPTED: StatusCode
[src]
pub const ACCEPTED: StatusCode
[src]202 Accepted [RFC7231, Section 6.3.3]
pub const NON_AUTHORITATIVE_INFORMATION: StatusCode
[src]
pub const NON_AUTHORITATIVE_INFORMATION: StatusCode
[src]203 Non-Authoritative Information [RFC7231, Section 6.3.4]
pub const NO_CONTENT: StatusCode
[src]
pub const NO_CONTENT: StatusCode
[src]204 No Content [RFC7231, Section 6.3.5]
pub const RESET_CONTENT: StatusCode
[src]
pub const RESET_CONTENT: StatusCode
[src]205 Reset Content [RFC7231, Section 6.3.6]
pub const PARTIAL_CONTENT: StatusCode
[src]
pub const PARTIAL_CONTENT: StatusCode
[src]206 Partial Content [RFC7233, Section 4.1]
pub const MULTI_STATUS: StatusCode
[src]
pub const MULTI_STATUS: StatusCode
[src]207 Multi-Status [RFC4918]
pub const ALREADY_REPORTED: StatusCode
[src]
pub const ALREADY_REPORTED: StatusCode
[src]208 Already Reported [RFC5842]
pub const IM_USED: StatusCode
[src]
pub const IM_USED: StatusCode
[src]226 IM Used [RFC3229]
pub const MULTIPLE_CHOICES: StatusCode
[src]
pub const MULTIPLE_CHOICES: StatusCode
[src]300 Multiple Choices [RFC7231, Section 6.4.1]
pub const MOVED_PERMANENTLY: StatusCode
[src]
pub const MOVED_PERMANENTLY: StatusCode
[src]301 Moved Permanently [RFC7231, Section 6.4.2]
pub const FOUND: StatusCode
[src]
pub const FOUND: StatusCode
[src]302 Found [RFC7231, Section 6.4.3]
pub const SEE_OTHER: StatusCode
[src]
pub const SEE_OTHER: StatusCode
[src]303 See Other [RFC7231, Section 6.4.4]
pub const NOT_MODIFIED: StatusCode
[src]
pub const NOT_MODIFIED: StatusCode
[src]304 Not Modified [RFC7232, Section 4.1]
pub const USE_PROXY: StatusCode
[src]
pub const USE_PROXY: StatusCode
[src]305 Use Proxy [RFC7231, Section 6.4.5]
pub const TEMPORARY_REDIRECT: StatusCode
[src]
pub const TEMPORARY_REDIRECT: StatusCode
[src]307 Temporary Redirect [RFC7231, Section 6.4.7]
pub const PERMANENT_REDIRECT: StatusCode
[src]
pub const PERMANENT_REDIRECT: StatusCode
[src]308 Permanent Redirect [RFC7238]
pub const BAD_REQUEST: StatusCode
[src]
pub const BAD_REQUEST: StatusCode
[src]400 Bad Request [RFC7231, Section 6.5.1]
pub const UNAUTHORIZED: StatusCode
[src]
pub const UNAUTHORIZED: StatusCode
[src]401 Unauthorized [RFC7235, Section 3.1]
pub const PAYMENT_REQUIRED: StatusCode
[src]
pub const PAYMENT_REQUIRED: StatusCode
[src]402 Payment Required [RFC7231, Section 6.5.2]
pub const FORBIDDEN: StatusCode
[src]
pub const FORBIDDEN: StatusCode
[src]403 Forbidden [RFC7231, Section 6.5.3]
pub const NOT_FOUND: StatusCode
[src]
pub const NOT_FOUND: StatusCode
[src]404 Not Found [RFC7231, Section 6.5.4]
pub const METHOD_NOT_ALLOWED: StatusCode
[src]
pub const METHOD_NOT_ALLOWED: StatusCode
[src]405 Method Not Allowed [RFC7231, Section 6.5.5]
pub const NOT_ACCEPTABLE: StatusCode
[src]
pub const NOT_ACCEPTABLE: StatusCode
[src]406 Not Acceptable [RFC7231, Section 6.5.6]
pub const PROXY_AUTHENTICATION_REQUIRED: StatusCode
[src]
pub const PROXY_AUTHENTICATION_REQUIRED: StatusCode
[src]407 Proxy Authentication Required [RFC7235, Section 3.2]
pub const REQUEST_TIMEOUT: StatusCode
[src]
pub const REQUEST_TIMEOUT: StatusCode
[src]408 Request Timeout [RFC7231, Section 6.5.7]
pub const CONFLICT: StatusCode
[src]
pub const CONFLICT: StatusCode
[src]409 Conflict [RFC7231, Section 6.5.8]
pub const GONE: StatusCode
[src]
pub const GONE: StatusCode
[src]410 Gone [RFC7231, Section 6.5.9]
pub const LENGTH_REQUIRED: StatusCode
[src]
pub const LENGTH_REQUIRED: StatusCode
[src]411 Length Required [RFC7231, Section 6.5.10]
pub const PRECONDITION_FAILED: StatusCode
[src]
pub const PRECONDITION_FAILED: StatusCode
[src]412 Precondition Failed [RFC7232, Section 4.2]
pub const PAYLOAD_TOO_LARGE: StatusCode
[src]
pub const PAYLOAD_TOO_LARGE: StatusCode
[src]413 Payload Too Large [RFC7231, Section 6.5.11]
pub const URI_TOO_LONG: StatusCode
[src]
pub const URI_TOO_LONG: StatusCode
[src]414 URI Too Long [RFC7231, Section 6.5.12]
pub const UNSUPPORTED_MEDIA_TYPE: StatusCode
[src]
pub const UNSUPPORTED_MEDIA_TYPE: StatusCode
[src]415 Unsupported Media Type [RFC7231, Section 6.5.13]
pub const RANGE_NOT_SATISFIABLE: StatusCode
[src]
pub const RANGE_NOT_SATISFIABLE: StatusCode
[src]416 Range Not Satisfiable [RFC7233, Section 4.4]
pub const EXPECTATION_FAILED: StatusCode
[src]
pub const EXPECTATION_FAILED: StatusCode
[src]417 Expectation Failed [RFC7231, Section 6.5.14]
pub const IM_A_TEAPOT: StatusCode
[src]
pub const IM_A_TEAPOT: StatusCode
[src]418 I’m a teapot [curiously not registered by IANA but RFC2324]
pub const MISDIRECTED_REQUEST: StatusCode
[src]
pub const MISDIRECTED_REQUEST: StatusCode
[src]421 Misdirected Request RFC7540, Section 9.1.2
pub const UNPROCESSABLE_ENTITY: StatusCode
[src]
pub const UNPROCESSABLE_ENTITY: StatusCode
[src]422 Unprocessable Entity [RFC4918]
pub const LOCKED: StatusCode
[src]
pub const LOCKED: StatusCode
[src]423 Locked [RFC4918]
pub const FAILED_DEPENDENCY: StatusCode
[src]
pub const FAILED_DEPENDENCY: StatusCode
[src]424 Failed Dependency [RFC4918]
pub const UPGRADE_REQUIRED: StatusCode
[src]
pub const UPGRADE_REQUIRED: StatusCode
[src]426 Upgrade Required [RFC7231, Section 6.5.15]
pub const PRECONDITION_REQUIRED: StatusCode
[src]
pub const PRECONDITION_REQUIRED: StatusCode
[src]428 Precondition Required [RFC6585]
pub const TOO_MANY_REQUESTS: StatusCode
[src]
pub const TOO_MANY_REQUESTS: StatusCode
[src]429 Too Many Requests [RFC6585]
pub const REQUEST_HEADER_FIELDS_TOO_LARGE: StatusCode
[src]
pub const REQUEST_HEADER_FIELDS_TOO_LARGE: StatusCode
[src]431 Request Header Fields Too Large [RFC6585]
pub const UNAVAILABLE_FOR_LEGAL_REASONS: StatusCode
[src]
pub const UNAVAILABLE_FOR_LEGAL_REASONS: StatusCode
[src]451 Unavailable For Legal Reasons [RFC7725]
pub const INTERNAL_SERVER_ERROR: StatusCode
[src]
pub const INTERNAL_SERVER_ERROR: StatusCode
[src]500 Internal Server Error [RFC7231, Section 6.6.1]
pub const NOT_IMPLEMENTED: StatusCode
[src]
pub const NOT_IMPLEMENTED: StatusCode
[src]501 Not Implemented [RFC7231, Section 6.6.2]
pub const BAD_GATEWAY: StatusCode
[src]
pub const BAD_GATEWAY: StatusCode
[src]502 Bad Gateway [RFC7231, Section 6.6.3]
pub const SERVICE_UNAVAILABLE: StatusCode
[src]
pub const SERVICE_UNAVAILABLE: StatusCode
[src]503 Service Unavailable [RFC7231, Section 6.6.4]
pub const GATEWAY_TIMEOUT: StatusCode
[src]
pub const GATEWAY_TIMEOUT: StatusCode
[src]504 Gateway Timeout [RFC7231, Section 6.6.5]
pub const HTTP_VERSION_NOT_SUPPORTED: StatusCode
[src]
pub const HTTP_VERSION_NOT_SUPPORTED: StatusCode
[src]505 HTTP Version Not Supported [RFC7231, Section 6.6.6]
pub const VARIANT_ALSO_NEGOTIATES: StatusCode
[src]
pub const VARIANT_ALSO_NEGOTIATES: StatusCode
[src]506 Variant Also Negotiates [RFC2295]
pub const INSUFFICIENT_STORAGE: StatusCode
[src]
pub const INSUFFICIENT_STORAGE: StatusCode
[src]507 Insufficient Storage [RFC4918]
pub const LOOP_DETECTED: StatusCode
[src]
pub const LOOP_DETECTED: StatusCode
[src]508 Loop Detected [RFC5842]
pub const NOT_EXTENDED: StatusCode
[src]
pub const NOT_EXTENDED: StatusCode
[src]510 Not Extended [RFC2774]
pub const NETWORK_AUTHENTICATION_REQUIRED: StatusCode
[src]
pub const NETWORK_AUTHENTICATION_REQUIRED: StatusCode
[src]511 Network Authentication Required [RFC6585]
Trait Implementations
impl Clone for StatusCode
[src]
impl Clone for StatusCode
[src]pub fn clone(&self) -> StatusCode
[src]
pub fn clone(&self) -> StatusCode
[src]Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]Performs copy-assignment from source
. Read more
impl Debug for StatusCode
[src]
impl Debug for StatusCode
[src]impl Default for StatusCode
[src]
impl Default for StatusCode
[src]pub fn default() -> StatusCode
[src]
pub fn default() -> StatusCode
[src]Returns the “default value” for a type. Read more
impl Display for StatusCode
[src]
impl Display for StatusCode
[src]Formats the status code, including the canonical reason.
Example
assert_eq!(format!("{}", StatusCode::OK), "200 OK");
impl<'a> From<&'a StatusCode> for StatusCode
[src]
impl<'a> From<&'a StatusCode> for StatusCode
[src]pub fn from(t: &'a StatusCode) -> StatusCode
[src]
pub fn from(t: &'a StatusCode) -> StatusCode
[src]Performs the conversion.
impl FromStr for StatusCode
[src]
impl FromStr for StatusCode
[src]type Err = InvalidStatusCode
type Err = InvalidStatusCode
The associated error which can be returned from parsing.
pub fn from_str(s: &str) -> Result<StatusCode, InvalidStatusCode>
[src]
pub fn from_str(s: &str) -> Result<StatusCode, InvalidStatusCode>
[src]Parses a string s
to return a value of this type. Read more
impl Hash for StatusCode
[src]
impl Hash for StatusCode
[src]impl Ord for StatusCode
[src]
impl Ord for StatusCode
[src]impl PartialEq<StatusCode> for StatusCode
[src]
impl PartialEq<StatusCode> for StatusCode
[src]pub fn eq(&self, other: &StatusCode) -> bool
[src]
pub fn eq(&self, other: &StatusCode) -> bool
[src]This method tests for self
and other
values to be equal, and is used
by ==
. Read more
pub fn ne(&self, other: &StatusCode) -> bool
[src]
pub fn ne(&self, other: &StatusCode) -> bool
[src]This method tests for !=
.
impl PartialEq<u16> for StatusCode
[src]
impl PartialEq<u16> for StatusCode
[src]impl PartialOrd<StatusCode> for StatusCode
[src]
impl PartialOrd<StatusCode> for StatusCode
[src]pub fn partial_cmp(&self, other: &StatusCode) -> Option<Ordering>
[src]
pub fn partial_cmp(&self, other: &StatusCode) -> Option<Ordering>
[src]This method returns an ordering between self
and other
values if one exists. Read more
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]This method tests less than (for self
and other
) and is used by the <
operator. Read more
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl<'a> TryFrom<&'a [u8]> for StatusCode
[src]
impl<'a> TryFrom<&'a [u8]> for StatusCode
[src]type Error = InvalidStatusCode
type Error = InvalidStatusCode
The type returned in the event of a conversion error.
impl<'a> TryFrom<&'a str> for StatusCode
[src]
impl<'a> TryFrom<&'a str> for StatusCode
[src]type Error = InvalidStatusCode
type Error = InvalidStatusCode
The type returned in the event of a conversion error.
pub fn try_from(
t: &'a str
) -> Result<StatusCode, <StatusCode as TryFrom<&'a str>>::Error>
[src]
pub fn try_from(
t: &'a str
) -> Result<StatusCode, <StatusCode as TryFrom<&'a str>>::Error>
[src]Performs the conversion.
impl TryFrom<u16> for StatusCode
[src]
impl TryFrom<u16> for StatusCode
[src]type Error = InvalidStatusCode
type Error = InvalidStatusCode
The type returned in the event of a conversion error.
pub fn try_from(
t: u16
) -> Result<StatusCode, <StatusCode as TryFrom<u16>>::Error>
[src]
pub fn try_from(
t: u16
) -> Result<StatusCode, <StatusCode as TryFrom<u16>>::Error>
[src]Performs the conversion.
impl Copy for StatusCode
[src]
impl Eq for StatusCode
[src]
impl StructuralEq for StatusCode
[src]
impl StructuralPartialEq for StatusCode
[src]
Auto Trait Implementations
impl RefUnwindSafe for StatusCode
impl Send for StatusCode
impl Sync for StatusCode
impl Unpin for StatusCode
impl UnwindSafe for StatusCode
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]pub fn equivalent(&self, key: &K) -> bool
[src]
pub fn equivalent(&self, key: &K) -> bool
[src]Compare self to key
and return true
if they are equal.
impl<T> Instrument for T
[src]
impl<T> Instrument for T
[src]fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
fn in_current_span(self) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
pub fn to_subset(&self) -> Option<SS>
pub fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
pub fn is_in_subset(&self) -> bool
pub fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
pub unsafe fn to_subset_unchecked(&self) -> SS
pub unsafe fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
pub fn from_subset(element: &SS) -> SP
pub fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,