Enum hyper::StatusCode
[−]
[src]
pub enum StatusCode { Continue, SwitchingProtocols, Processing, Ok, Created, Accepted, NonAuthoritativeInformation, NoContent, ResetContent, PartialContent, MultiStatus, AlreadyReported, ImUsed, MultipleChoices, MovedPermanently, Found, SeeOther, NotModified, UseProxy, TemporaryRedirect, PermanentRedirect, BadRequest, Unauthorized, PaymentRequired, Forbidden, NotFound, MethodNotAllowed, NotAcceptable, ProxyAuthenticationRequired, RequestTimeout, Conflict, Gone, LengthRequired, PreconditionFailed, PayloadTooLarge, UriTooLong, UnsupportedMediaType, RangeNotSatisfiable, ExpectationFailed, ImATeapot, MisdirectedRequest, UnprocessableEntity, Locked, FailedDependency, UpgradeRequired, PreconditionRequired, TooManyRequests, RequestHeaderFieldsTooLarge, UnavailableForLegalReasons, InternalServerError, NotImplemented, BadGateway, ServiceUnavailable, GatewayTimeout, HttpVersionNotSupported, VariantAlsoNegotiates, InsufficientStorage, LoopDetected, NotExtended, NetworkAuthenticationRequired, Unregistered(u16), }
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.
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
Continue
100 Continue [RFC7231, Section 6.2.1]
SwitchingProtocols
101 Switching Protocols [RFC7231, Section 6.2.2]
Processing
102 Processing [RFC2518]
Ok
200 OK [RFC7231, Section 6.3.1]
Created
201 Created [RFC7231, Section 6.3.2]
Accepted
202 Accepted [RFC7231, Section 6.3.3]
NonAuthoritativeInformation
203 Non-Authoritative Information [RFC7231, Section 6.3.4]
NoContent
204 No Content [RFC7231, Section 6.3.5]
ResetContent
205 Reset Content [RFC7231, Section 6.3.6]
PartialContent
206 Partial Content [RFC7233, Section 4.1]
MultiStatus
207 Multi-Status [RFC4918]
AlreadyReported
208 Already Reported [RFC5842]
ImUsed
226 IM Used [RFC3229]
MultipleChoices
300 Multiple Choices [RFC7231, Section 6.4.1]
MovedPermanently
301 Moved Permanently [RFC7231, Section 6.4.2]
Found
302 Found [RFC7231, Section 6.4.3]
SeeOther
303 See Other [RFC7231, Section 6.4.4]
NotModified
304 Not Modified [RFC7232, Section 4.1]
UseProxy
305 Use Proxy [RFC7231, Section 6.4.5]
TemporaryRedirect
307 Temporary Redirect [RFC7231, Section 6.4.7]
PermanentRedirect
308 Permanent Redirect [RFC7238]
BadRequest
400 Bad Request [RFC7231, Section 6.5.1]
401 Unauthorized [RFC7235, Section 3.1]
PaymentRequired
402 Payment Required [RFC7231, Section 6.5.2]
Forbidden
403 Forbidden [RFC7231, Section 6.5.3]
NotFound
404 Not Found [RFC7231, Section 6.5.4]
MethodNotAllowed
405 Method Not Allowed [RFC7231, Section 6.5.5]
NotAcceptable
406 Not Acceptable [RFC7231, Section 6.5.6]
ProxyAuthenticationRequired
407 Proxy Authentication Required [RFC7235, Section 3.2]
RequestTimeout
408 Request Timeout [RFC7231, Section 6.5.7]
Conflict
409 Conflict [RFC7231, Section 6.5.8]
Gone
410 Gone [RFC7231, Section 6.5.9]
LengthRequired
411 Length Required [RFC7231, Section 6.5.10]
PreconditionFailed
412 Precondition Failed [RFC7232, Section 4.2]
PayloadTooLarge
413 Payload Too Large [RFC7231, Section 6.5.11]
UriTooLong
414 URI Too Long [RFC7231, Section 6.5.12]
UnsupportedMediaType
415 Unsupported Media Type [RFC7231, Section 6.5.13]
RangeNotSatisfiable
416 Range Not Satisfiable [RFC7233, Section 4.4]
ExpectationFailed
417 Expectation Failed [RFC7231, Section 6.5.14]
ImATeapot
418 I'm a teapot [curiously, not registered by IANA, but RFC2324]
MisdirectedRequest
421 Misdirected Request RFC7540, Section 9.1.2
UnprocessableEntity
422 Unprocessable Entity [RFC4918]
Locked
423 Locked [RFC4918]
FailedDependency
424 Failed Dependency [RFC4918]
UpgradeRequired
426 Upgrade Required [RFC7231, Section 6.5.15]
PreconditionRequired
428 Precondition Required [RFC6585]
TooManyRequests
429 Too Many Requests [RFC6585]
RequestHeaderFieldsTooLarge
431 Request Header Fields Too Large [RFC6585]
451 Unavailable For Legal Reasons [RFC7725]
InternalServerError
500 Internal Server Error [RFC7231, Section 6.6.1]
NotImplemented
501 Not Implemented [RFC7231, Section 6.6.2]
BadGateway
502 Bad Gateway [RFC7231, Section 6.6.3]
503 Service Unavailable [RFC7231, Section 6.6.4]
GatewayTimeout
504 Gateway Timeout [RFC7231, Section 6.6.5]
HttpVersionNotSupported
505 HTTP Version Not Supported [RFC7231, Section 6.6.6]
VariantAlsoNegotiates
506 Variant Also Negotiates [RFC2295]
InsufficientStorage
507 Insufficient Storage [RFC4918]
LoopDetected
508 Loop Detected [RFC5842]
NotExtended
510 Not Extended [RFC2774]
NetworkAuthenticationRequired
511 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 StatusCode
pub fn try_from(n: u16) -> Result<StatusCode, InvalidStatusCode>
[src]
pub fn try_from(n: u16) -> Result<StatusCode, InvalidStatusCode>
Try to convert a u16
into a StatusCode
.
Errors
This will return an error if the provided argument is not within the
range 100...599
.
Note
This function is temporary. When the TryFrom
trait becomes stable,
this will be deprecated and replaced by TryFrom<u16>
.
pub fn as_u16(&self) -> u16
[src]
pub fn as_u16(&self) -> u16
Get the u16
code from this StatusCode
.
Also available as From
/Into<u16>
.
Example
use hyper::StatusCode; let status = StatusCode::Ok; assert_eq!(status.as_u16(), 200); // Into let num: u16 = status.into(); assert_eq!(num, 200); // From let other = u16::from(status); assert_eq!(num, other);
pub 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 is_informational(&self) -> bool
[src]
pub fn is_informational(&self) -> bool
Check if this StatusCode
is within 100-199.
pub fn is_success(&self) -> bool
[src]
pub fn is_success(&self) -> bool
Check if this StatusCode
is within 200-299.
pub fn is_redirection(&self) -> bool
[src]
pub fn is_redirection(&self) -> bool
Check if this StatusCode
is within 300-399.
pub fn is_client_error(&self) -> bool
[src]
pub fn is_client_error(&self) -> bool
Check if this StatusCode
is within 400-499.
pub fn is_server_error(&self) -> bool
[src]
pub fn is_server_error(&self) -> bool
Check if this StatusCode
is within 500-599.
pub fn is_strange_status(&self) -> bool
[src]
pub fn is_strange_status(&self) -> bool
Check if this StatusCode
is not within 100-599.
Trait Implementations
impl Debug for StatusCode
[src]
impl Debug for StatusCode
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Hash for StatusCode
[src]
impl Hash for StatusCode
fn hash<__H: Hasher>(&self, __arg_0: &mut __H)
[src]
fn hash<__H: Hasher>(&self, __arg_0: &mut __H)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl Copy for StatusCode
[src]
impl Copy for StatusCode
impl Display for StatusCode
[src]
impl Display for StatusCode
Formats 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>");
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl PartialEq for StatusCode
[src]
impl PartialEq for StatusCode
fn eq(&self, other: &StatusCode) -> bool
[src]
fn eq(&self, other: &StatusCode) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl Eq for StatusCode
[src]
impl Eq for StatusCode
impl Clone for StatusCode
[src]
impl Clone for StatusCode
fn clone(&self) -> StatusCode
[src]
fn clone(&self) -> StatusCode
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)
Performs copy-assignment from source
. Read more
impl PartialOrd for StatusCode
[src]
impl PartialOrd for StatusCode
fn partial_cmp(&self, other: &StatusCode) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &StatusCode) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
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
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
fn gt(&self, other: &Rhs) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
fn ge(&self, other: &Rhs) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Ord for StatusCode
[src]
impl Ord for StatusCode
fn cmp(&self, other: &StatusCode) -> Ordering
[src]
fn cmp(&self, other: &StatusCode) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl Default for StatusCode
[src]
impl Default for StatusCode
fn default() -> StatusCode
[src]
fn default() -> StatusCode
Returns the "default value" for a type. Read more
impl From<StatusCode> for u16
[src]
impl From<StatusCode> for u16
fn from(code: StatusCode) -> u16
[src]
fn from(code: StatusCode) -> u16
Performs the conversion.
Auto Trait Implementations
impl Send for StatusCode
impl Send for StatusCode
impl Sync for StatusCode
impl Sync for StatusCode