[−][src]Enum hyper::status::StatusCode
An HTTP status code (status-code in RFC 7230 et al.).
This enum contains all common status codes and an Unregistered
extension variant. It allows status codes in the range [0, 65535], as any
u16 integer may be used as a status code for XHR requests. It is
recommended to only use values between [100, 599], since only these are
defined as valid status codes with a status class by HTTP.
If you encounter a status code that you do not know how to deal with, you
should treat it as the x00 status code—e.g. for code 123, treat it as
100 (Continue). This can be achieved with
self.class().default_code():
let status = StatusCode::Unregistered(123); assert_eq!(status.class().default_code(), StatusCode::Continue);
IANA maintain the Hypertext Transfer Protocol (HTTP) Status Code Registry which is the source for this enum (with one exception, 418 I'm a teapot, which is inexplicably not in the register).
Variants
Continue100 Continue [RFC7231, Section 6.2.1]
SwitchingProtocols101 Switching Protocols [RFC7231, Section 6.2.2]
Processing102 Processing [RFC2518]
Ok200 OK [RFC7231, Section 6.3.1]
Created201 Created [RFC7231, Section 6.3.2]
Accepted202 Accepted [RFC7231, Section 6.3.3]
NonAuthoritativeInformation203 Non-Authoritative Information [RFC7231, Section 6.3.4]
NoContent204 No Content [RFC7231, Section 6.3.5]
ResetContent205 Reset Content [RFC7231, Section 6.3.6]
PartialContent206 Partial Content [RFC7233, Section 4.1]
MultiStatus207 Multi-Status [RFC4918]
AlreadyReported208 Already Reported [RFC5842]
ImUsed226 IM Used [RFC3229]
MultipleChoices300 Multiple Choices [RFC7231, Section 6.4.1]
MovedPermanently301 Moved Permanently [RFC7231, Section 6.4.2]
Found302 Found [RFC7231, Section 6.4.3]
SeeOther303 See Other [RFC7231, Section 6.4.4]
NotModified304 Not Modified [RFC7232, Section 4.1]
UseProxy305 Use Proxy [RFC7231, Section 6.4.5]
TemporaryRedirect307 Temporary Redirect [RFC7231, Section 6.4.7]
PermanentRedirect308 Permanent Redirect [RFC7238]
BadRequest400 Bad Request [RFC7231, Section 6.5.1]
401 Unauthorized [RFC7235, Section 3.1]
PaymentRequired402 Payment Required [RFC7231, Section 6.5.2]
Forbidden403 Forbidden [RFC7231, Section 6.5.3]
NotFound404 Not Found [RFC7231, Section 6.5.4]
MethodNotAllowed405 Method Not Allowed [RFC7231, Section 6.5.5]
NotAcceptable406 Not Acceptable [RFC7231, Section 6.5.6]
ProxyAuthenticationRequired407 Proxy Authentication Required [RFC7235, Section 3.2]
RequestTimeout408 Request Timeout [RFC7231, Section 6.5.7]
Conflict409 Conflict [RFC7231, Section 6.5.8]
Gone410 Gone [RFC7231, Section 6.5.9]
LengthRequired411 Length Required [RFC7231, Section 6.5.10]
PreconditionFailed412 Precondition Failed [RFC7232, Section 4.2]
PayloadTooLarge413 Payload Too Large [RFC7231, Section 6.5.11]
UriTooLong414 URI Too Long [RFC7231, Section 6.5.12]
UnsupportedMediaType415 Unsupported Media Type [RFC7231, Section 6.5.13]
RangeNotSatisfiable416 Range Not Satisfiable [RFC7233, Section 4.4]
ExpectationFailed417 Expectation Failed [RFC7231, Section 6.5.14]
ImATeapot418 I'm a teapot [curiously, not registered by IANA, but RFC2324]
MisdirectedRequest421 Misdirected Request RFC7540, Section 9.1.2
UnprocessableEntity422 Unprocessable Entity [RFC4918]
Locked423 Locked [RFC4918]
FailedDependency424 Failed Dependency [RFC4918]
UpgradeRequired426 Upgrade Required [RFC7231, Section 6.5.15]
PreconditionRequired428 Precondition Required [RFC6585]
TooManyRequests429 Too Many Requests [RFC6585]
RequestHeaderFieldsTooLarge431 Request Header Fields Too Large [RFC6585]
451 Unavailable For Legal Reasons [RFC7725]
InternalServerError500 Internal Server Error [RFC7231, Section 6.6.1]
NotImplemented501 Not Implemented [RFC7231, Section 6.6.2]
BadGateway502 Bad Gateway [RFC7231, Section 6.6.3]
503 Service Unavailable [RFC7231, Section 6.6.4]
GatewayTimeout504 Gateway Timeout [RFC7231, Section 6.6.5]
HttpVersionNotSupported505 HTTP Version Not Supported [RFC7231, Section 6.6.6]
VariantAlsoNegotiates506 Variant Also Negotiates [RFC2295]
InsufficientStorage507 Insufficient Storage [RFC4918]
LoopDetected508 Loop Detected [RFC5842]
NotExtended510 Not Extended [RFC2774]
NetworkAuthenticationRequired511 Network Authentication Required [RFC6585]
Unregistered(u16)A status code not in the IANA HTTP status code registry or very well known
Methods
impl StatusCode[src]
impl StatusCodepub fn canonical_reason(&self) -> Option<&'static str>[src]
pub fn canonical_reason(&self) -> Option<&'static str>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 the reason phrase is abolished from transmission, and so this canonical reason phrase really is the only reason phrase you’ll find.
pub fn class(&self) -> StatusClass[src]
pub fn class(&self) -> StatusClassDetermine the class of a status code, based on its first digit.
pub fn is_informational(&self) -> bool[src]
pub fn is_informational(&self) -> boolCheck if class is Informational.
pub fn is_success(&self) -> bool[src]
pub fn is_success(&self) -> boolCheck if class is Success.
pub fn is_redirection(&self) -> bool[src]
pub fn is_redirection(&self) -> boolCheck if class is Redirection.
pub fn is_client_error(&self) -> bool[src]
pub fn is_client_error(&self) -> boolCheck if class is ClientError.
pub fn is_server_error(&self) -> bool[src]
pub fn is_server_error(&self) -> boolCheck if class is ServerError.
pub fn is_strange_status(&self) -> bool[src]
pub fn is_strange_status(&self) -> boolCheck if class is NoClass
Trait Implementations
impl PartialEq<StatusCode> for StatusCode[src]
impl PartialEq<StatusCode> for StatusCodefn eq(&self, other: &StatusCode) -> bool[src]
fn eq(&self, other: &StatusCode) -> bool#[must_use]
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ne(&self, other: &Rhs) -> boolThis method tests for !=.
impl Clone for StatusCode[src]
impl Clone for StatusCodefn clone(&self) -> StatusCode[src]
fn clone(&self) -> StatusCodefn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
impl Copy for StatusCode[src]
impl Copy for StatusCodeimpl Ord for StatusCode[src]
impl Ord for StatusCodefn cmp(&self, other: &StatusCode) -> Ordering[src]
fn cmp(&self, other: &StatusCode) -> Orderingfn max(self, other: Self) -> Self1.21.0[src]
fn max(self, other: Self) -> SelfCompares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self1.21.0[src]
fn min(self, other: Self) -> SelfCompares and returns the minimum of two values. Read more
impl Eq for StatusCode[src]
impl Eq for StatusCodeimpl PartialOrd<StatusCode> for StatusCode[src]
impl PartialOrd<StatusCode> for StatusCodefn partial_cmp(&self, other: &StatusCode) -> Option<Ordering>[src]
fn partial_cmp(&self, other: &StatusCode) -> Option<Ordering>#[must_use]
fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn lt(&self, other: &Rhs) -> boolThis method tests less than (for self and other) and is used by the < operator. Read more
#[must_use]
fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> boolThis method tests less than or equal to (for self and other) and is used by the <= operator. Read more
#[must_use]
fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> boolThis method tests greater than (for self and other) and is used by the > operator. Read more
#[must_use]
fn ge(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> boolThis method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
impl Display for StatusCode[src]
impl Display for StatusCodeFormats the status code, including the canonical reason.
assert_eq!(format!("{}", ImATeapot), "418 I'm a teapot"); assert_eq!(format!("{}", Unregistered(123)), "123 <unknown status code>");
impl Debug for StatusCode[src]
impl Debug for StatusCodeimpl Hash for StatusCode[src]
impl Hash for StatusCodeAuto Trait Implementations
impl Send for StatusCode
impl Send for StatusCodeimpl Sync for StatusCode
impl Sync for StatusCodeBlanket Implementations
impl<T> ToString for T where
T: Display + ?Sized, [src]
impl<T> ToString for T where
T: Display + ?Sized, impl<T> From for T[src]
impl<T> From for Timpl<T, U> Into for T where
U: From<T>, [src]
impl<T, U> Into for T where
U: From<T>, impl<T> ToOwned for T where
T: Clone, [src]
impl<T> ToOwned for T where
T: Clone, impl<T, U> TryFrom for T where
T: From<U>, [src]
impl<T, U> TryFrom for T where
T: From<U>, type Error = !
try_from)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>impl<T> Borrow for T where
T: ?Sized, [src]
impl<T> Borrow for T where
T: ?Sized, impl<T> Any for T where
T: 'static + ?Sized, [src]
impl<T> Any for T where
T: 'static + ?Sized, fn get_type_id(&self) -> TypeId[src]
fn get_type_id(&self) -> TypeIdimpl<T, U> TryInto for T where
U: TryFrom<T>, [src]
impl<T, U> TryInto for T where
U: TryFrom<T>, type Error = <U as TryFrom<T>>::Error
try_from)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>impl<T> BorrowMut for T where
T: ?Sized, [src]
impl<T> BorrowMut for T where
T: ?Sized, fn borrow_mut(&mut self) -> &mut T[src]
fn borrow_mut(&mut self) -> &mut Timpl<T> Typeable for T where
T: Any, [src]
impl<T> Typeable for T where
T: Any,