pub enum HttpStatus {
Show 63 variants
Continue,
SwitchingProtocols,
Processing,
EarlyHints,
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,
TooEarly,
UpgradeRequired,
PreconditionRequired,
TooManyRequests,
RequestHeaderFieldsTooLarge,
UnavailableForLegalReasons,
InternalServerError,
NotImplemented,
BadGateway,
ServiceUnavailable,
GatewayTimeout,
HTTPVersionNotSupported,
VariantAlsoNegotiates,
InsufficientStorage,
LoopDetected,
NotExtended,
NetworkAuthenticationRequired,
Unknown,
}Expand description
Enumeration of HTTP status
Variants§
Continue
100 Continue
SwitchingProtocols
101 Switching Protocols
Processing
102 Processing (WebDAV)
EarlyHints
103 Early Hints
Ok
200 OK
Created
201 Created
Accepted
202 Accepted
NonAuthoritativeInformation
203 Non-Authoritative Information
NoContent
204 No Content
ResetContent
205 Reset Content
PartialContent
206 Partial Content
MultiStatus
207 Multi-Status (WebDAV)
AlreadyReported
208 Already Reported (WebDAV)
IMUsed
226 IM Used
MultipleChoices
300 Multiple Choices
MovedPermanently
301 Moved Permanently
Found
302 Found
SeeOther
303 See Other
NotModified
304 Not Modified
UseProxy
305 Use Proxy
TemporaryRedirect
307 Temporary Redirect
PermanentRedirect
308 Permanent Redirect
BadRequest
400 Bad Request
401 Unauthorized
PaymentRequired
402 Payment Required
Forbidden
403 Forbidden
NotFound
404 Not Found
MethodNotAllowed
405 Method Not Allowed
NotAcceptable
406 Not Acceptable
ProxyAuthenticationRequired
407 Proxy Authentication Required
RequestTimeout
408 Request Timeout
Conflict
409 Conflict
Gone
410 Gone
LengthRequired
411 Length Required
PreconditionFailed
412 Precondition Failed
PayloadTooLarge
413 Payload Too Large
URITooLong
414 URI Too Long
UnsupportedMediaType
415 Unsupported Media Type
RangeNotSatisfiable
416 Range Not Satisfiable
ExpectationFailed
417 Expectation Failed
ImATeapot
418 I’m a teapot
MisdirectedRequest
421 Misdirected Request
UnprocessableEntity
422 Unprocessable Entity (WebDAV)
Locked
423 Locked (WebDAV)
FailedDependency
424 Failed Dependency (WebDAV)
TooEarly
425 Too Early
UpgradeRequired
426 Upgrade Required
PreconditionRequired
428 Precondition Required
TooManyRequests
429 Too Many Requests
RequestHeaderFieldsTooLarge
431 Request Header Fields Too Large
451 Unavailable For Legal Reasons
InternalServerError
500 Internal Server Error
NotImplemented
501 Not Implemented
BadGateway
502 Bad Gateway
503 Service Unavailable
GatewayTimeout
504 Gateway Timeout
HTTPVersionNotSupported
505 HTTP Version Not Supported
VariantAlsoNegotiates
506 Variant Also Negotiates
InsufficientStorage
507 Insufficient Storage (WebDAV)
LoopDetected
508 Loop Detected (WebDAV)
NotExtended
510 Not Extended
NetworkAuthenticationRequired
511 Network Authentication Required
Unknown
Unknown status code
Implementations§
Source§impl HttpStatus
The HttpStatus enum represents the HTTP status codes.
impl HttpStatus
The HttpStatus enum represents the HTTP status codes.
It maps common HTTP status codes to their respective meanings. It provides methods to retrieve the corresponding numeric code as well as the associated status text. Additionally, it implements conversion from a string representation of the status code.
Sourcepub fn code(&self) -> usize
pub fn code(&self) -> usize
Returns the numeric HTTP status code associated with this status code variant.
This method returns the corresponding HTTP numeric status code based on the HttpStatus variant.
For example:
Self::Okreturns 200.Self::BadRequestreturns 400.Self::Unknownreturns 0 (the default for unrecognized status codes).
§Parameters
&self: A reference to theHttpStatusenum instance. This represents the specific variant of theHttpStatusenum that the method is called on.
§Return Value
ResponseStatusCode: The numeric HTTP status code associated with theHttpStatusvariant. For example:
Sourcepub fn phrase(code: usize) -> String
pub fn phrase(code: usize) -> String
Converts an HTTP status code to its corresponding textual description.
This method matches a given numeric HTTP status code and returns the corresponding
textual representation defined in the HttpStatus enum.
§Parameters
code: AResponseStatusCoderepresenting the HTTP status code to convert.
§Return Value
String: A string representing the textual description of the HTTP status code.
Sourcepub fn same(&self, code_str: &str) -> bool
pub fn same(&self, code_str: &str) -> bool
Compares the current status code with a given string representation.
This method checks if the given code_str matches either the numeric HTTP status code
returned by code() or the string representation of the status code variant.
The comparison is case-insensitive.
§Parameters
&self: A reference to theHttpStatusenum instance.code_str: A string slice containing the status code to compare against.
§Return Value
bool: Returnstrueifcode_strmatches the numeric code or the string representation ofself, otherwisefalse.
Trait Implementations§
Source§impl Clone for HttpStatus
impl Clone for HttpStatus
Source§fn clone(&self) -> HttpStatus
fn clone(&self) -> HttpStatus
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for HttpStatus
impl Debug for HttpStatus
Source§impl Default for HttpStatus
impl Default for HttpStatus
Source§fn default() -> HttpStatus
fn default() -> HttpStatus
Source§impl Display for HttpStatus
impl Display for HttpStatus
Source§impl FromStr for HttpStatus
impl FromStr for HttpStatus
Source§impl PartialEq for HttpStatus
impl PartialEq for HttpStatus
impl Eq for HttpStatus
impl StructuralPartialEq for HttpStatus
Auto Trait Implementations§
impl Freeze for HttpStatus
impl RefUnwindSafe for HttpStatus
impl Send for HttpStatus
impl Sync for HttpStatus
impl Unpin for HttpStatus
impl UnwindSafe for HttpStatus
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.