pub enum StatusCode {
Show 44 variants
Continue,
SwitchingProtocols,
OK,
Created,
Accepted,
NonAuthoritative,
NoContent,
ResetContent,
PartialContent,
MultipleChoices,
MovedPermanently,
Found,
SeeOther,
NotModified,
UseProxy,
TemporaryRedirect,
PermanentRedirect,
BadRequest,
Unauthorized,
PaymentRequired,
Forbidden,
NotFound,
MethodNotAllowed,
NotAcceptable,
ProxyAuthenticationRequired,
RequestTimeout,
Conflict,
Gone,
LengthRequired,
PreconditionFailed,
RequestEntityTooLarge,
ContentTooLarge,
RequestURITooLong,
UnsupportedMediaType,
RequestedRangeNotSatisfiable,
ExpectationFailed,
InternalServerError,
NotImplemented,
BadGateway,
ServiceUnavailable,
GatewayTimeout,
VersionNotSupported,
CustomStr(u16, [u8; 3], &'static str),
CustomString(u16, [u8; 3], String),
}Expand description
Represents an HTTP status code.
Variants§
Continue
100 Continue: Continue with request.
SwitchingProtocols
101 Switching Protocols: Protocol upgrade.
OK
200 OK: Request succeeded.
Created
201 Created: Resource created.
Accepted
202 Accepted: Request received, but not yet acted upon.
NonAuthoritative
203 Non-Authoritative Information: Request processed, but response is from another source.
NoContent
204 No Content: There is no content to send for this request.
ResetContent
205 Reset Content: Indicates that the document which sent this request should be reset.
PartialContent
206 Partial Content: This response only contains part of a resource.
MultipleChoices
300 Multiple Choice: The request has multiple possible responses.
MovedPermanently
301 Moved Permanently: The resource has moved permanently to a new location.
Found
302 Found: The resource has moved temporarily to a new location.
SeeOther
303 See Other: The resource can be found under a different URI.
NotModified
304 Not Modified: The resource has not been modified since the last request.
UseProxy
305 Use Proxy: The requested resource must be accessed through a proxy.
TemporaryRedirect
307 Temporary Redirect: The resource has moved temporarily to a new location.
PermanentRedirect
308 Permanent Redirect: The resource has moved permanently to a new location.
BadRequest
400 Bad Request: The request could not be understood by the server.
401 Unauthorized: The request requires user authentication.
PaymentRequired
402 Payment Required: Reserved non-standard status code.
Usually used to indicate that an application wants more money to perform an operation.
Forbidden
403 Forbidden: The client is not allowed to access this content.
NotFound
404 Not Found: The server can not find the requested resource.
MethodNotAllowed
405 Method Not Allowed: The method specified in the request is not allowed for the resource.
NotAcceptable
406 Not Acceptable: No content that meets the criteria is available.
ProxyAuthenticationRequired
407 Proxy Authentication Required: The client must first authenticate itself with a proxy.
RequestTimeout
408 Request Timeout: The server timed out waiting for the request.
Conflict
409 Conflict: The request could not be completed because of a conflict with the server’s current state.
Gone
410 Gone: The requested resource is no longer available.
LengthRequired
411 Length Required: The request did not specify the length of its content.
PreconditionFailed
412 Precondition Failed: The server does not meet one of the client’s preconditions.
RequestEntityTooLarge
413 Payload Too Large: The request is larger than the server is willing or able to process.
ContentTooLarge
413 Content Too Large: The request is larger than the server is willing or able to process. Newer version of RequestEntityTooLarge
RequestURITooLong
414 URI Too Long: The URI provided was too long for the server to process.
UnsupportedMediaType
415 Unsupported Media Type: The request entity has a media type which the server or resource does not support.
RequestedRangeNotSatisfiable
416 Requested Range Not Satisfiable: The range specified in the Range header cannot be fulfilled.
ExpectationFailed
417 Expectation Failed: The expectation given in the Expect header could not be met by the server.
InternalServerError
500 Internal Server Error: The server encountered an unexpected error which prevented it from fulfilling the request.
NotImplemented
501 Not Implemented: The server does not support the functionality required to fulfill the request.
BadGateway
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 temporarily unable to handle the request.
GatewayTimeout
504 Gateway Timeout: The server, while acting as a gateway or proxy, did not receive a timely response from the upstream server.
VersionNotSupported
505 HTTP Version Not Supported: The server does not support the HTTP protocol version used in the request.
CustomStr(u16, [u8; 3], &'static str)
User defined status code, some applications need non-standard custom status codes.
CustomString(u16, [u8; 3], String)
User defined status code, some applications need non-standard custom status codes.
Implementations§
Source§impl StatusCode
impl StatusCode
Sourcepub const fn from_custom(code: u16, status_line: &'static str) -> Self
pub const fn from_custom(code: u16, status_line: &'static str) -> Self
Creates a custom Status code from a static message and code. Codes with more or less than 3 digits or status lines with invalid content will silently turn into Internal server error. This method is intended to be called from const code so you can put your custom codes into const variables.
Sourcepub fn from_custom_string<T: ToString>(
code: u16,
status_line: &T,
) -> Option<Self>
pub fn from_custom_string<T: ToString>( code: u16, status_line: &T, ) -> Option<Self>
Creates a custom Status code from a dynamic (possibly heap allocated) message and code.
§Returns
None: Codes with more or less than 3 digits or status lines with invalid content
Sourcepub const fn from_well_known_code_or_500(code: u16) -> Self
pub const fn from_well_known_code_or_500(code: u16) -> Self
This fn returns a status code representing a well known code that is specified in the RFC for http. If the code is not well known then the fn returns the same value it would return for “500 Internal Server Error”
Sourcepub const fn from_well_known_code(code: u16) -> Option<Self>
pub const fn from_well_known_code(code: u16) -> Option<Self>
This fn returns a status code representing a well known code that is specified in the RFC for http.
§Returns
None: the code was not well known.
Sourcepub const fn status_line_static(&self) -> Option<&'static str>
pub const fn status_line_static(&self) -> Option<&'static str>
Returns the status line as an Option<&’static str> This fn will return None for heap allocated status lines.
Sourcepub fn status_line(&self) -> &str
pub fn status_line(&self) -> &str
Returns the status line as a &str
Sourcepub const fn code_as_utf(&self) -> &[u8; 3]
pub const fn code_as_utf(&self) -> &[u8; 3]
Returns the 3-digit code as 3 byte utf-8 representation.
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 more