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
sourceimpl StatusCode
impl StatusCode
sourcepub fn from_u16(src: u16) -> Result<StatusCode, InvalidStatusCode>
Available on crate feature http-api
only.
pub fn from_u16(src: u16) -> Result<StatusCode, InvalidStatusCode>
http-api
only.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());
sourcepub fn from_bytes(src: &[u8]) -> Result<StatusCode, InvalidStatusCode>
Available on crate feature http-api
only.
pub fn from_bytes(src: &[u8]) -> Result<StatusCode, InvalidStatusCode>
http-api
only.Converts a &u8 to a status code
sourcepub fn as_u16(&self) -> u16
Available on crate feature http-api
only.
pub fn as_u16(&self) -> u16
http-api
only.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);
sourcepub fn as_str(&self) -> &str
Available on crate feature http-api
only.
pub fn as_str(&self) -> &str
http-api
only.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");
sourcepub fn canonical_reason(&self) -> Option<&'static str>
Available on crate feature http-api
only.
pub fn canonical_reason(&self) -> Option<&'static str>
http-api
only.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"));
sourcepub fn is_informational(&self) -> bool
Available on crate feature http-api
only.
pub fn is_informational(&self) -> bool
http-api
only.Check if status is within 100-199.
sourcepub fn is_success(&self) -> bool
Available on crate feature http-api
only.
pub fn is_success(&self) -> bool
http-api
only.Check if status is within 200-299.
sourcepub fn is_redirection(&self) -> bool
Available on crate feature http-api
only.
pub fn is_redirection(&self) -> bool
http-api
only.Check if status is within 300-399.
sourcepub fn is_client_error(&self) -> bool
Available on crate feature http-api
only.
pub fn is_client_error(&self) -> bool
http-api
only.Check if status is within 400-499.
sourcepub fn is_server_error(&self) -> bool
Available on crate feature http-api
only.
pub fn is_server_error(&self) -> bool
http-api
only.Check if status is within 500-599.
sourceimpl StatusCode
impl StatusCode
sourcepub const CONTINUE: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(100) })
Available on crate feature http-api
only.
pub const CONTINUE: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(100) })
http-api
only.100 Continue [RFC7231, Section 6.2.1]
sourcepub const SWITCHING_PROTOCOLS: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(101) })
Available on crate feature http-api
only.
pub const SWITCHING_PROTOCOLS: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(101) })
http-api
only.101 Switching Protocols [RFC7231, Section 6.2.2]
sourcepub const PROCESSING: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(102) })
Available on crate feature http-api
only.
pub const PROCESSING: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(102) })
http-api
only.102 Processing [RFC2518]
sourcepub const OK: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(200) })
Available on crate feature http-api
only.
pub const OK: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(200) })
http-api
only.200 OK [RFC7231, Section 6.3.1]
sourcepub const CREATED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(201) })
Available on crate feature http-api
only.
pub const CREATED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(201) })
http-api
only.201 Created [RFC7231, Section 6.3.2]
sourcepub const ACCEPTED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(202) })
Available on crate feature http-api
only.
pub const ACCEPTED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(202) })
http-api
only.202 Accepted [RFC7231, Section 6.3.3]
sourcepub const NON_AUTHORITATIVE_INFORMATION: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(203) })
Available on crate feature http-api
only.
pub const NON_AUTHORITATIVE_INFORMATION: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(203) })
http-api
only.203 Non-Authoritative Information [RFC7231, Section 6.3.4]
sourcepub const NO_CONTENT: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(204) })
Available on crate feature http-api
only.
pub const NO_CONTENT: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(204) })
http-api
only.204 No Content [RFC7231, Section 6.3.5]
sourcepub const RESET_CONTENT: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(205) })
Available on crate feature http-api
only.
pub const RESET_CONTENT: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(205) })
http-api
only.205 Reset Content [RFC7231, Section 6.3.6]
sourcepub const PARTIAL_CONTENT: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(206) })
Available on crate feature http-api
only.
pub const PARTIAL_CONTENT: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(206) })
http-api
only.206 Partial Content [RFC7233, Section 4.1]
sourcepub const MULTI_STATUS: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(207) })
Available on crate feature http-api
only.
pub const MULTI_STATUS: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(207) })
http-api
only.207 Multi-Status [RFC4918]
sourcepub const ALREADY_REPORTED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(208) })
Available on crate feature http-api
only.
pub const ALREADY_REPORTED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(208) })
http-api
only.208 Already Reported [RFC5842]
sourcepub const IM_USED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(226) })
Available on crate feature http-api
only.
pub const IM_USED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(226) })
http-api
only.226 IM Used [RFC3229]
sourcepub const MULTIPLE_CHOICES: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(300) })
Available on crate feature http-api
only.
pub const MULTIPLE_CHOICES: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(300) })
http-api
only.300 Multiple Choices [RFC7231, Section 6.4.1]
sourcepub const MOVED_PERMANENTLY: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(301) })
Available on crate feature http-api
only.
pub const MOVED_PERMANENTLY: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(301) })
http-api
only.301 Moved Permanently [RFC7231, Section 6.4.2]
sourcepub const FOUND: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(302) })
Available on crate feature http-api
only.
pub const FOUND: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(302) })
http-api
only.302 Found [RFC7231, Section 6.4.3]
sourcepub const SEE_OTHER: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(303) })
Available on crate feature http-api
only.
pub const SEE_OTHER: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(303) })
http-api
only.303 See Other [RFC7231, Section 6.4.4]
sourcepub const NOT_MODIFIED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(304) })
Available on crate feature http-api
only.
pub const NOT_MODIFIED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(304) })
http-api
only.304 Not Modified [RFC7232, Section 4.1]
sourcepub const USE_PROXY: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(305) })
Available on crate feature http-api
only.
pub const USE_PROXY: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(305) })
http-api
only.305 Use Proxy [RFC7231, Section 6.4.5]
sourcepub const TEMPORARY_REDIRECT: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(307) })
Available on crate feature http-api
only.
pub const TEMPORARY_REDIRECT: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(307) })
http-api
only.307 Temporary Redirect [RFC7231, Section 6.4.7]
sourcepub const PERMANENT_REDIRECT: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(308) })
Available on crate feature http-api
only.
pub const PERMANENT_REDIRECT: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(308) })
http-api
only.308 Permanent Redirect [RFC7238]
sourcepub const BAD_REQUEST: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(400) })
Available on crate feature http-api
only.
pub const BAD_REQUEST: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(400) })
http-api
only.400 Bad Request [RFC7231, Section 6.5.1]
sourcepub const UNAUTHORIZED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(401) })
Available on crate feature http-api
only.
pub const UNAUTHORIZED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(401) })
http-api
only.401 Unauthorized [RFC7235, Section 3.1]
sourcepub const PAYMENT_REQUIRED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(402) })
Available on crate feature http-api
only.
pub const PAYMENT_REQUIRED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(402) })
http-api
only.402 Payment Required [RFC7231, Section 6.5.2]
sourcepub const FORBIDDEN: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(403) })
Available on crate feature http-api
only.
pub const FORBIDDEN: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(403) })
http-api
only.403 Forbidden [RFC7231, Section 6.5.3]
sourcepub const NOT_FOUND: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(404) })
Available on crate feature http-api
only.
pub const NOT_FOUND: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(404) })
http-api
only.404 Not Found [RFC7231, Section 6.5.4]
sourcepub const METHOD_NOT_ALLOWED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(405) })
Available on crate feature http-api
only.
pub const METHOD_NOT_ALLOWED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(405) })
http-api
only.405 Method Not Allowed [RFC7231, Section 6.5.5]
sourcepub const NOT_ACCEPTABLE: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(406) })
Available on crate feature http-api
only.
pub const NOT_ACCEPTABLE: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(406) })
http-api
only.406 Not Acceptable [RFC7231, Section 6.5.6]
sourcepub const PROXY_AUTHENTICATION_REQUIRED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(407) })
Available on crate feature http-api
only.
pub const PROXY_AUTHENTICATION_REQUIRED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(407) })
http-api
only.407 Proxy Authentication Required [RFC7235, Section 3.2]
sourcepub const REQUEST_TIMEOUT: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(408) })
Available on crate feature http-api
only.
pub const REQUEST_TIMEOUT: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(408) })
http-api
only.408 Request Timeout [RFC7231, Section 6.5.7]
sourcepub const CONFLICT: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(409) })
Available on crate feature http-api
only.
pub const CONFLICT: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(409) })
http-api
only.409 Conflict [RFC7231, Section 6.5.8]
sourcepub const GONE: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(410) })
Available on crate feature http-api
only.
pub const GONE: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(410) })
http-api
only.410 Gone [RFC7231, Section 6.5.9]
sourcepub const LENGTH_REQUIRED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(411) })
Available on crate feature http-api
only.
pub const LENGTH_REQUIRED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(411) })
http-api
only.411 Length Required [RFC7231, Section 6.5.10]
sourcepub const PRECONDITION_FAILED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(412) })
Available on crate feature http-api
only.
pub const PRECONDITION_FAILED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(412) })
http-api
only.412 Precondition Failed [RFC7232, Section 4.2]
sourcepub const PAYLOAD_TOO_LARGE: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(413) })
Available on crate feature http-api
only.
pub const PAYLOAD_TOO_LARGE: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(413) })
http-api
only.413 Payload Too Large [RFC7231, Section 6.5.11]
sourcepub const URI_TOO_LONG: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(414) })
Available on crate feature http-api
only.
pub const URI_TOO_LONG: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(414) })
http-api
only.414 URI Too Long [RFC7231, Section 6.5.12]
sourcepub const UNSUPPORTED_MEDIA_TYPE: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(415) })
Available on crate feature http-api
only.
pub const UNSUPPORTED_MEDIA_TYPE: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(415) })
http-api
only.415 Unsupported Media Type [RFC7231, Section 6.5.13]
sourcepub const RANGE_NOT_SATISFIABLE: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(416) })
Available on crate feature http-api
only.
pub const RANGE_NOT_SATISFIABLE: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(416) })
http-api
only.416 Range Not Satisfiable [RFC7233, Section 4.4]
sourcepub const EXPECTATION_FAILED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(417) })
Available on crate feature http-api
only.
pub const EXPECTATION_FAILED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(417) })
http-api
only.417 Expectation Failed [RFC7231, Section 6.5.14]
sourcepub const IM_A_TEAPOT: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(418) })
Available on crate feature http-api
only.
pub const IM_A_TEAPOT: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(418) })
http-api
only.418 I’m a teapot [curiously not registered by IANA but RFC2324]
sourcepub const MISDIRECTED_REQUEST: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(421) })
Available on crate feature http-api
only.
pub const MISDIRECTED_REQUEST: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(421) })
http-api
only.421 Misdirected Request RFC7540, Section 9.1.2
sourcepub const UNPROCESSABLE_ENTITY: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(422) })
Available on crate feature http-api
only.
pub const UNPROCESSABLE_ENTITY: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(422) })
http-api
only.422 Unprocessable Entity [RFC4918]
sourcepub const LOCKED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(423) })
Available on crate feature http-api
only.
pub const LOCKED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(423) })
http-api
only.423 Locked [RFC4918]
sourcepub const FAILED_DEPENDENCY: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(424) })
Available on crate feature http-api
only.
pub const FAILED_DEPENDENCY: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(424) })
http-api
only.424 Failed Dependency [RFC4918]
sourcepub const UPGRADE_REQUIRED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(426) })
Available on crate feature http-api
only.
pub const UPGRADE_REQUIRED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(426) })
http-api
only.426 Upgrade Required [RFC7231, Section 6.5.15]
sourcepub const PRECONDITION_REQUIRED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(428) })
Available on crate feature http-api
only.
pub const PRECONDITION_REQUIRED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(428) })
http-api
only.428 Precondition Required [RFC6585]
sourcepub const TOO_MANY_REQUESTS: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(429) })
Available on crate feature http-api
only.
pub const TOO_MANY_REQUESTS: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(429) })
http-api
only.429 Too Many Requests [RFC6585]
sourcepub const REQUEST_HEADER_FIELDS_TOO_LARGE: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(431) })
Available on crate feature http-api
only.
pub const REQUEST_HEADER_FIELDS_TOO_LARGE: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(431) })
http-api
only.431 Request Header Fields Too Large [RFC6585]
sourcepub const UNAVAILABLE_FOR_LEGAL_REASONS: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(451) })
Available on crate feature http-api
only.
pub const UNAVAILABLE_FOR_LEGAL_REASONS: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(451) })
http-api
only.451 Unavailable For Legal Reasons [RFC7725]
sourcepub const INTERNAL_SERVER_ERROR: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(500) })
Available on crate feature http-api
only.
pub const INTERNAL_SERVER_ERROR: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(500) })
http-api
only.500 Internal Server Error [RFC7231, Section 6.6.1]
sourcepub const NOT_IMPLEMENTED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(501) })
Available on crate feature http-api
only.
pub const NOT_IMPLEMENTED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(501) })
http-api
only.501 Not Implemented [RFC7231, Section 6.6.2]
sourcepub const BAD_GATEWAY: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(502) })
Available on crate feature http-api
only.
pub const BAD_GATEWAY: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(502) })
http-api
only.502 Bad Gateway [RFC7231, Section 6.6.3]
sourcepub const SERVICE_UNAVAILABLE: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(503) })
Available on crate feature http-api
only.
pub const SERVICE_UNAVAILABLE: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(503) })
http-api
only.503 Service Unavailable [RFC7231, Section 6.6.4]
sourcepub const GATEWAY_TIMEOUT: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(504) })
Available on crate feature http-api
only.
pub const GATEWAY_TIMEOUT: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(504) })
http-api
only.504 Gateway Timeout [RFC7231, Section 6.6.5]
sourcepub const HTTP_VERSION_NOT_SUPPORTED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(505) })
Available on crate feature http-api
only.
pub const HTTP_VERSION_NOT_SUPPORTED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(505) })
http-api
only.505 HTTP Version Not Supported [RFC7231, Section 6.6.6]
sourcepub const VARIANT_ALSO_NEGOTIATES: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(506) })
Available on crate feature http-api
only.
pub const VARIANT_ALSO_NEGOTIATES: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(506) })
http-api
only.506 Variant Also Negotiates [RFC2295]
sourcepub const INSUFFICIENT_STORAGE: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(507) })
Available on crate feature http-api
only.
pub const INSUFFICIENT_STORAGE: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(507) })
http-api
only.507 Insufficient Storage [RFC4918]
sourcepub const LOOP_DETECTED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(508) })
Available on crate feature http-api
only.
pub const LOOP_DETECTED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(508) })
http-api
only.508 Loop Detected [RFC5842]
sourcepub const NOT_EXTENDED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(510) })
Available on crate feature http-api
only.
pub const NOT_EXTENDED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(510) })
http-api
only.510 Not Extended [RFC2774]
sourcepub const NETWORK_AUTHENTICATION_REQUIRED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(511) })
Available on crate feature http-api
only.
pub const NETWORK_AUTHENTICATION_REQUIRED: StatusCode = StatusCode(unsafe { NonZeroU16::new_unchecked(511) })
http-api
only.511 Network Authentication Required [RFC6585]
Trait Implementations
sourceimpl Clone for StatusCode
impl Clone for StatusCode
sourcefn clone(&self) -> StatusCode
fn clone(&self) -> StatusCode
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for StatusCode
impl Debug for StatusCode
sourceimpl Default for StatusCode
impl Default for StatusCode
sourcefn default() -> StatusCode
fn default() -> StatusCode
Returns the “default value” for a type. Read more
sourceimpl Display for StatusCode
impl Display for StatusCode
Formats the status code, including the canonical reason.
Example
assert_eq!(format!("{}", StatusCode::OK), "200 OK");
sourceimpl<'a> From<&'a StatusCode> for StatusCode
impl<'a> From<&'a StatusCode> for StatusCode
sourcefn from(t: &'a StatusCode) -> StatusCode
fn from(t: &'a StatusCode) -> StatusCode
Converts to this type from the input type.
sourceimpl FromStr for StatusCode
impl FromStr for StatusCode
type Err = InvalidStatusCode
type Err = InvalidStatusCode
The associated error which can be returned from parsing.
sourcefn from_str(s: &str) -> Result<StatusCode, InvalidStatusCode>
fn from_str(s: &str) -> Result<StatusCode, InvalidStatusCode>
Parses a string s
to return a value of this type. Read more
sourceimpl Hash for StatusCode
impl Hash for StatusCode
sourceimpl Ord for StatusCode
impl Ord for StatusCode
sourceimpl PartialEq<StatusCode> for StatusCode
impl PartialEq<StatusCode> for StatusCode
sourcefn 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 ==
. Read more
sourcefn ne(&self, other: &StatusCode) -> bool
fn ne(&self, other: &StatusCode) -> bool
This method tests for !=
.
sourceimpl PartialEq<u16> for StatusCode
impl PartialEq<u16> for StatusCode
sourceimpl PartialOrd<StatusCode> for StatusCode
impl PartialOrd<StatusCode> for StatusCode
sourcefn partial_cmp(&self, other: &StatusCode) -> Option<Ordering>
fn partial_cmp(&self, other: &StatusCode) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl<'a> TryFrom<&'a [u8]> for StatusCode
impl<'a> TryFrom<&'a [u8]> for StatusCode
type Error = InvalidStatusCode
type Error = InvalidStatusCode
The type returned in the event of a conversion error.
sourcefn try_from(
t: &'a [u8]
) -> Result<StatusCode, <StatusCode as TryFrom<&'a [u8]>>::Error>
fn try_from(
t: &'a [u8]
) -> Result<StatusCode, <StatusCode as TryFrom<&'a [u8]>>::Error>
Performs the conversion.
sourceimpl<'a> TryFrom<&'a str> for StatusCode
impl<'a> TryFrom<&'a str> for StatusCode
type Error = InvalidStatusCode
type Error = InvalidStatusCode
The type returned in the event of a conversion error.
sourcefn try_from(
t: &'a str
) -> Result<StatusCode, <StatusCode as TryFrom<&'a str>>::Error>
fn try_from(
t: &'a str
) -> Result<StatusCode, <StatusCode as TryFrom<&'a str>>::Error>
Performs the conversion.
sourceimpl TryFrom<u16> for StatusCode
impl TryFrom<u16> for StatusCode
type Error = InvalidStatusCode
type Error = InvalidStatusCode
The type returned in the event of a conversion error.
sourcefn try_from(t: u16) -> Result<StatusCode, <StatusCode as TryFrom<u16>>::Error>
fn try_from(t: u16) -> Result<StatusCode, <StatusCode as TryFrom<u16>>::Error>
Performs the conversion.
impl Copy for StatusCode
impl Eq for StatusCode
impl StructuralEq for StatusCode
impl StructuralPartialEq for StatusCode
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.