StatusCode

Enum StatusCode 

Source
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.

§

Unauthorized

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

👎Deprecated

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.

§

ServiceUnavailable

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

Source

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.

Source

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

Source

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”

Source

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.

Source

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.

Source

pub fn status_line(&self) -> &str

Returns the status line as a &str

Source

pub const fn code_as_utf(&self) -> &[u8; 3]

Returns the 3-digit code as 3 byte utf-8 representation.

Source

pub const fn code(&self) -> u16

Returns the code as u16. This value is guaranteed to be in >= 100 <= 999 range.

Trait Implementations§

Source§

impl Clone for StatusCode

Source§

fn clone(&self) -> StatusCode

Returns a duplicate 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 StatusCode

Source§

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

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

impl PartialEq for StatusCode

Source§

fn eq(&self, other: &StatusCode) -> 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 StatusCode

Source§

impl StructuralPartialEq for StatusCode

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<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> Same for T

Source§

type Output = T

Should always be Self
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, 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.