Enum HttpStatus

Source
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

§

Unauthorized

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

§

UnavailableForLegalReasons

451 Unavailable For Legal Reasons

§

InternalServerError

500 Internal Server Error

§

NotImplemented

501 Not Implemented

§

BadGateway

502 Bad Gateway

§

ServiceUnavailable

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.

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.

Source

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::Ok returns 200.
  • Self::BadRequest returns 400.
  • Self::Unknown returns 0 (the default for unrecognized status codes).
§Parameters
  • &self: A reference to the HttpStatus enum instance. This represents the specific variant of the HttpStatus enum that the method is called on.
§Return Value
  • ResponseStatusCode: The numeric HTTP status code associated with the HttpStatus variant. For example:
Source

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: A ResponseStatusCode representing the HTTP status code to convert.
§Return Value
  • String: A string representing the textual description of the HTTP status code.
Source

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 the HttpStatus enum instance.
  • code_str: A string slice containing the status code to compare against.
§Return Value
  • bool: Returns true if code_str matches the numeric code or the string representation of self, otherwise false.

Trait Implementations§

Source§

impl Clone for HttpStatus

Source§

fn clone(&self) -> HttpStatus

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for HttpStatus

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for HttpStatus

Source§

fn default() -> HttpStatus

Returns the “default value” for a type. Read more
Source§

impl Display for HttpStatus

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl FromStr for HttpStatus

Source§

type Err = ()

The associated error which can be returned from parsing.
Source§

fn from_str(code_str: &str) -> Result<HttpStatus, <HttpStatus as FromStr>::Err>

Parses a string s to return a value of this type. Read more
Source§

impl PartialEq for HttpStatus

Source§

fn eq(&self, other: &HttpStatus) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for HttpStatus

Source§

impl StructuralPartialEq for HttpStatus

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> AnySend for T
where T: Any + Send,

Source§

impl<T> AnySendClone for T
where T: Any + Send + Clone,

Source§

impl<T> AnySendSync for T
where T: Any + Send + Sync,

Source§

impl<T> AnySendSyncClone for T
where T: Any + Send + Sync + Clone,

Source§

impl<T> AnySync for T
where T: Any + Sync,

Source§

impl<T> AnySyncClone for T
where T: Any + Sync + Clone,

Source§

impl<T> BroadcastMapTrait for T
where T: Clone + Debug,

Source§

impl<T> BroadcastTrait for T
where T: Clone + Debug,

Source§

impl<T> ErasedDestructor for T
where T: 'static,