pub enum StatusCode {
Show 63 variants
CONTINUE = 100,
SWITCHING_PROTOCOLS = 101,
PROCESSING = 102,
EARLY_HINTS = 103,
OK = 200,
CREATED = 201,
ACCEPTED = 202,
NON_AUTHORITATIVE_INFORMATION = 203,
NO_CONTENT = 204,
RESET_CONTENT = 205,
PARTIAL_CONTENT = 206,
MULTI_STATUS = 207,
ALREADY_REPORTED = 208,
IM_USED = 226,
MULTIPLE_CHOICES = 300,
MOVED_PERMANENTLY = 301,
FOUND = 302,
SEE_OTHER = 303,
NOT_MODIFIED = 304,
USE_PROXY = 305,
TEMPORARY_REDIRECT = 307,
PERMANENT_REDIRECT = 308,
BAD_REQUEST = 400,
UNAUTHORIZED = 401,
PAYMENT_REQUIRED = 402,
FORBIDDEN = 403,
NOT_FOUND = 404,
METHOD_NOT_ALLOWED = 405,
NOT_ACCEPTABLE = 406,
PROXY_AUTHENTICATION_REQUIRED = 407,
REQUEST_TIMEOUT = 408,
CONFLICT = 409,
GONE = 410,
LENGTH_REQUIRED = 411,
PRECONDITION_FAILED = 412,
PAYLOAD_TOO_LARGE = 413,
URI_TOO_LONG = 414,
UNSUPPORTED_MEDIA_TYPE = 415,
RANGE_NOT_SATISFIABLE = 416,
EXPECTATION_FAILED = 417,
IM_A_TEAPOT = 418,
MISDIRECTED_REQUEST = 421,
UNPROCESSABLE_ENTITY = 422,
LOCKED = 423,
FAILED_DEPENDENCY = 424,
TOO_EARLY = 425,
UPGRADE_REQUIRED = 426,
PRECONDITION_REQUIRED = 428,
TOO_MANY_REQUESTS = 429,
REQUEST_HEADER_FIELDS_TOO_LARGE = 431,
UNAVAILABLE_FOR_LEGAL_REASONS = 451,
INTERNAL_SERVER_ERROR = 500,
NOT_IMPLEMENTED = 501,
BAD_GATEWAY = 502,
SERVICE_UNAVAILABLE = 503,
GATEWAY_TIMEOUT = 504,
HTTP_VERSION_NOT_SUPPORTED = 505,
VARIANT_ALSO_NEGOTIATES = 506,
INSUFFICIENT_STORAGE = 507,
LOOP_DETECTED = 508,
NOT_EXTENDED = 510,
NETWORK_AUTHENTICATION_REQUIRED = 511,
UNKNOWN = 0,
}Expand description
Represents HTTP status codes.
This enum includes the most common HTTP status codes and provides methods to check status code categories, convert between numeric and string representations, and perform other common operations.
Variants§
CONTINUE = 100
SWITCHING_PROTOCOLS = 101
PROCESSING = 102
EARLY_HINTS = 103
OK = 200
CREATED = 201
ACCEPTED = 202
NON_AUTHORITATIVE_INFORMATION = 203
NO_CONTENT = 204
RESET_CONTENT = 205
PARTIAL_CONTENT = 206
MULTI_STATUS = 207
ALREADY_REPORTED = 208
IM_USED = 226
MULTIPLE_CHOICES = 300
MOVED_PERMANENTLY = 301
FOUND = 302
SEE_OTHER = 303
NOT_MODIFIED = 304
USE_PROXY = 305
TEMPORARY_REDIRECT = 307
PERMANENT_REDIRECT = 308
BAD_REQUEST = 400
UNAUTHORIZED = 401
PAYMENT_REQUIRED = 402
FORBIDDEN = 403
NOT_FOUND = 404
METHOD_NOT_ALLOWED = 405
NOT_ACCEPTABLE = 406
PROXY_AUTHENTICATION_REQUIRED = 407
REQUEST_TIMEOUT = 408
CONFLICT = 409
GONE = 410
LENGTH_REQUIRED = 411
PRECONDITION_FAILED = 412
PAYLOAD_TOO_LARGE = 413
URI_TOO_LONG = 414
UNSUPPORTED_MEDIA_TYPE = 415
RANGE_NOT_SATISFIABLE = 416
EXPECTATION_FAILED = 417
IM_A_TEAPOT = 418
MISDIRECTED_REQUEST = 421
UNPROCESSABLE_ENTITY = 422
LOCKED = 423
FAILED_DEPENDENCY = 424
TOO_EARLY = 425
UPGRADE_REQUIRED = 426
PRECONDITION_REQUIRED = 428
TOO_MANY_REQUESTS = 429
REQUEST_HEADER_FIELDS_TOO_LARGE = 431
UNAVAILABLE_FOR_LEGAL_REASONS = 451
INTERNAL_SERVER_ERROR = 500
NOT_IMPLEMENTED = 501
BAD_GATEWAY = 502
SERVICE_UNAVAILABLE = 503
GATEWAY_TIMEOUT = 504
HTTP_VERSION_NOT_SUPPORTED = 505
VARIANT_ALSO_NEGOTIATES = 506
INSUFFICIENT_STORAGE = 507
LOOP_DETECTED = 508
NOT_EXTENDED = 510
NETWORK_AUTHENTICATION_REQUIRED = 511
UNKNOWN = 0
Implementations§
Source§impl StatusCode
impl StatusCode
Sourcepub fn reason_phrase(&self) -> &'static str
pub fn reason_phrase(&self) -> &'static str
Gets only the reason phrase part of the status code.
§Returns
The reason phrase part of the status code.
Sourcepub fn from_u16(code: u16) -> StatusCode
pub fn from_u16(code: u16) -> StatusCode
Sourcepub fn from_string(code: &str) -> StatusCode
pub fn from_string(code: &str) -> StatusCode
Sourcepub fn is_informational(&self) -> bool
pub fn is_informational(&self) -> bool
Checks if the status code is informational (1xx).
§Returns
true if the status code is in the 1xx range, false otherwise.
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Checks if the status code indicates success (2xx).
§Returns
true if the status code is in the 2xx range, false otherwise.
Sourcepub fn is_redirection(&self) -> bool
pub fn is_redirection(&self) -> bool
Checks if the status code indicates redirection (3xx).
§Returns
true if the status code is in the 3xx range, false otherwise.
Sourcepub fn is_client_error(&self) -> bool
pub fn is_client_error(&self) -> bool
Checks if the status code indicates a client error (4xx).
§Returns
true if the status code is in the 4xx range, false otherwise.
Sourcepub fn is_server_error(&self) -> bool
pub fn is_server_error(&self) -> bool
Checks if the status code indicates a server error (5xx).
§Returns
true if the status code is in the 5xx range, false otherwise.
Sourcepub fn is_error(&self) -> bool
pub fn is_error(&self) -> bool
Checks if the status code indicates an error (4xx or 5xx).
§Returns
true if the status code is in the 4xx or 5xx range, false otherwise.
Sourcepub fn is_not_found(&self) -> bool
pub fn is_not_found(&self) -> bool
Checks if the status code indicates that the resource was not found (404).
§Returns
true if the status code is 404, false otherwise.
Sourcepub fn is_ok(&self) -> bool
pub fn is_ok(&self) -> bool
Checks if the status code indicates a successful response (200 OK).
§Returns
true if the status code is 200, false otherwise.
Sourcepub fn is_no_content(&self) -> bool
pub fn is_no_content(&self) -> bool
Checks if the status code indicates that the content should be omitted (204 No Content).
§Returns
true if the status code is 204, false otherwise.
Sourcepub fn is_created(&self) -> bool
pub fn is_created(&self) -> bool
Checks if the status code indicates that the requested resource was created (201 Created).
§Returns
true if the status code is 201, false otherwise.
Checks if the status code indicates that the client is not authorized (401 Unauthorized).
§Returns
true if the status code is 401, false otherwise.
Trait Implementations§
Source§impl Clone for StatusCode
impl Clone for StatusCode
Source§fn clone(&self) -> StatusCode
fn clone(&self) -> StatusCode
1.0.0 (const: unstable) · 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 Display for StatusCode
impl Display for StatusCode
impl Eq for StatusCode
Source§impl From<&HttpError> for StatusCode
Convert an HttpError into the most appropriate HTTP StatusCode.
impl From<&HttpError> for StatusCode
Convert an HttpError into the most appropriate HTTP StatusCode.
This is useful when you need to map an HttpError to a response status
code for error responses.
Source§fn from(err: &HttpError) -> StatusCode
fn from(err: &HttpError) -> StatusCode
Source§impl From<&str> for StatusCode
impl From<&str> for StatusCode
Source§fn from(code: &str) -> StatusCode
fn from(code: &str) -> StatusCode
Source§impl From<String> for StatusCode
impl From<String> for StatusCode
Source§fn from(code: String) -> StatusCode
fn from(code: String) -> StatusCode
Source§impl From<u16> for StatusCode
impl From<u16> for StatusCode
Source§fn from(code: u16) -> StatusCode
fn from(code: u16) -> StatusCode
Source§impl Hash for StatusCode
impl Hash for StatusCode
Source§impl PartialEq for StatusCode
impl PartialEq for StatusCode
impl StructuralPartialEq for StatusCode
Auto Trait Implementations§
impl Freeze for StatusCode
impl RefUnwindSafe for StatusCode
impl Send for StatusCode
impl Sync for StatusCode
impl Unpin for StatusCode
impl UnsafeUnpin for StatusCode
impl UnwindSafe for StatusCode
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<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> ParamValue for T
impl<T> ParamValue for T
Source§fn clone_box(&self) -> Box<dyn ParamValue>
fn clone_box(&self) -> Box<dyn ParamValue>
ParamValue. Read moreSource§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Any. Read moreSource§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Any. Read more