#[repr(u16)]pub enum StatusCode {
Show 41 variants
Continue = 100,
SwitchingProtocols = 101,
Ok = 200,
Created = 201,
Accepted = 202,
NonAuthoritativeInformation = 203,
NoContent = 204,
ResetContent = 205,
PartialContent = 206,
MultipleChoices = 300,
MovedPermanently = 301,
Found = 302,
SeeOther = 303,
NotModified = 304,
UseProxy = 305,
TemporaryRedirect = 307,
BadRequest = 400,
Unauthorized = 401,
PaymentRequired = 402,
Forbidden = 403,
NotFound = 404,
MethodNotAllowed = 405,
NotAcceptable = 406,
ProxyAuthenticationRequired = 407,
RequestTimeout = 408,
Conflict = 409,
Gone = 410,
LengthRequired = 411,
PreconditionFailed = 412,
RequestEntityTooLarge = 413,
RequestUriTooLong = 414,
UnsupportedMediaType = 415,
RequestedRangeNotSatisfiable = 416,
ExpectationFailed = 417,
InternalServerError = 500,
NotImplemented = 501,
BadGateway = 502,
ServiceUnavailable = 503,
GatewayTimeout = 504,
HttpVersionNotSupported = 505,
Other(u16),
}Expand description
HTTP/1.1 status codes as defined in RFC 2616 section 10
Variants§
Continue = 100
100 Continue: The server has received the request headers, and the client should proceed to send the request body.
SwitchingProtocols = 101
101 Switching Protocols: The requester has asked the server to switch protocols.
Ok = 200
200 OK: The request has succeeded.
Created = 201
201 Created: The request has been fulfilled and resulted in a new resource being created.
Accepted = 202
202 Accepted: The request has been accepted for processing, but the processing has not been completed.
NonAuthoritativeInformation = 203
203 Non-Authoritative Information: The server successfully processed the request, but is returning information that may be from another source.
NoContent = 204
204 No Content: The server successfully processed the request, but is not returning any content.
ResetContent = 205
205 Reset Content: The server successfully processed the request, but is not returning any content and requires that the requester reset the document view.
PartialContent = 206
206 Partial Content: The server is delivering only part of the resource due to a range header sent by the client.
MultipleChoices = 300
300 Multiple Choices: Indicates multiple options for the resource from which the client may choose.
MovedPermanently = 301
301 Moved Permanently: This and all future requests should be directed to the given URI.
Found = 302
302 Found: The resource was found but at a different URI.
SeeOther = 303
303 See Other: The response to the request can be found under another URI using a GET method.
NotModified = 304
304 Not Modified: Indicates that the resource has not been modified since the version specified by the request headers.
UseProxy = 305
305 Use Proxy: The requested resource is available only through a proxy.
TemporaryRedirect = 307
307 Temporary Redirect: The request should be repeated with another URI, but future requests should still use the original URI.
BadRequest = 400
400 Bad Request: The server could not understand the request due to invalid syntax.
401 Unauthorized: The client must authenticate itself to get the requested response.
PaymentRequired = 402
402 Payment Required: Reserved for future use.
Forbidden = 403
403 Forbidden: The client does not have access rights to the content.
NotFound = 404
404 Not Found: The server can not find the requested resource.
MethodNotAllowed = 405
405 Method Not Allowed: The request method is known by the server but is not supported by the target resource.
NotAcceptable = 406
406 Not Acceptable: The server cannot produce a response matching the list of acceptable values defined in the request’s headers.
ProxyAuthenticationRequired = 407
407 Proxy Authentication Required: The client must first authenticate itself with the proxy.
RequestTimeout = 408
408 Request Timeout: The server timed out waiting for the request.
Conflict = 409
409 Conflict: The request could not be completed due to a conflict with the current state of the resource.
Gone = 410
410 Gone: The resource requested is no longer available and will not be available again.
LengthRequired = 411
411 Length Required: The request did not specify the length of its content, which is required by the requested resource.
PreconditionFailed = 412
412 Precondition Failed: The server does not meet one of the preconditions that the requester put on the request.
RequestEntityTooLarge = 413
413 Request Entity Too Large: The request is larger than the server is willing or able to process.
RequestUriTooLong = 414
414 Request-URI Too Long: The URI provided was too long for the server to process.
UnsupportedMediaType = 415
415 Unsupported Media Type: The request entity has a media type which the server or resource does not support.
RequestedRangeNotSatisfiable = 416
416 Requested Range Not Satisfiable: The client has asked for a portion of the file, but the server cannot supply that portion.
ExpectationFailed = 417
417 Expectation Failed: The server cannot meet the requirements of the Expect request-header field.
InternalServerError = 500
500 Internal Server Error: The server has encountered a situation it doesn’t know how to handle.
NotImplemented = 501
501 Not Implemented: The request method is not supported by the server and cannot be handled.
BadGateway = 502
502 Bad Gateway: The server, while acting as a gateway or proxy, received an invalid response from the upstream server.
503 Service Unavailable: The server is not ready to handle the request.
GatewayTimeout = 504
504 Gateway Timeout: The server is acting as a gateway and cannot get a response in time.
HttpVersionNotSupported = 505
505 HTTP Version Not Supported: The HTTP version used in the request is not supported by the server.
Other(u16)
Any other (unknown or non-standard) status code
Implementations§
Source§impl StatusCode
impl StatusCode
Sourcepub fn is_success(self) -> bool
pub fn is_success(self) -> bool
Check if the status code indicates success (2xx status codes)
Sourcepub fn is_client_error(self) -> bool
pub fn is_client_error(self) -> bool
Check if the status code is a client error (4xx status codes)
Sourcepub fn is_server_error(self) -> bool
pub fn is_server_error(self) -> bool
Check if the status code is a server error (5xx status codes)
Trait Implementations§
Source§impl Clone for StatusCode
impl Clone for StatusCode
Source§fn clone(&self) -> StatusCode
fn clone(&self) -> StatusCode
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StatusCode
impl Debug for StatusCode
Source§impl From<u16> for StatusCode
impl From<u16> for StatusCode
Source§impl PartialEq for StatusCode
impl PartialEq for StatusCode
Source§impl TryFrom<&str> for StatusCode
impl TryFrom<&str> for StatusCode
Source§fn try_from(value: &str) -> Result<Self, Self::Error>
fn try_from(value: &str) -> Result<Self, Self::Error>
Parse a status code from a string slice.
§Examples
use nanofish::StatusCode;
let code: StatusCode = "200".try_into().unwrap();
assert_eq!(code, StatusCode::Ok);
let result: Result<StatusCode, _> = "999".try_into();
assert_eq!(result.unwrap(), StatusCode::Other(999));