Skip to main content

StatusCode

Enum StatusCode 

Source
#[repr(u16)]
pub enum StatusCode {
Show 41 variants Continue = 100, SwitchingProtocols = 101, Ok = 200, Created = 201, Accepted = 202, NonAuthoritativeInformation = 203, NoContent = 204, ResetContent = 205, PartialContent = 206, MultipleChoices = 300, MovedPermanently = 301, Found = 302, SeeOther = 303, NotModified = 304, UseProxy = 305, TemporaryRedirect = 307, BadRequest = 400, Unauthorized = 401, PaymentRequired = 402, Forbidden = 403, NotFound = 404, MethodNotAllowed = 405, NotAcceptable = 406, ProxyAuthenticationRequired = 407, RequestTimeout = 408, Conflict = 409, Gone = 410, LengthRequired = 411, PreconditionFailed = 412, RequestEntityTooLarge = 413, RequestUriTooLong = 414, UnsupportedMediaType = 415, RequestedRangeNotSatisfiable = 416, ExpectationFailed = 417, InternalServerError = 500, NotImplemented = 501, BadGateway = 502, ServiceUnavailable = 503, GatewayTimeout = 504, HttpVersionNotSupported = 505, Other(u16),
}
Expand description

HTTP/1.1 status codes as defined in RFC 2616 section 10

Variants§

§

Continue = 100

100 Continue: The server has received the request headers, and the client should proceed to send the request body.

§

SwitchingProtocols = 101

101 Switching Protocols: The requester has asked the server to switch protocols.

§

Ok = 200

200 OK: The request has succeeded.

§

Created = 201

201 Created: The request has been fulfilled and resulted in a new resource being created.

§

Accepted = 202

202 Accepted: The request has been accepted for processing, but the processing has not been completed.

§

NonAuthoritativeInformation = 203

203 Non-Authoritative Information: The server successfully processed the request, but is returning information that may be from another source.

§

NoContent = 204

204 No Content: The server successfully processed the request, but is not returning any content.

§

ResetContent = 205

205 Reset Content: The server successfully processed the request, but is not returning any content and requires that the requester reset the document view.

§

PartialContent = 206

206 Partial Content: The server is delivering only part of the resource due to a range header sent by the client.

§

MultipleChoices = 300

300 Multiple Choices: Indicates multiple options for the resource from which the client may choose.

§

MovedPermanently = 301

301 Moved Permanently: This and all future requests should be directed to the given URI.

§

Found = 302

302 Found: The resource was found but at a different URI.

§

SeeOther = 303

303 See Other: The response to the request can be found under another URI using a GET method.

§

NotModified = 304

304 Not Modified: Indicates that the resource has not been modified since the version specified by the request headers.

§

UseProxy = 305

305 Use Proxy: The requested resource is available only through a proxy.

§

TemporaryRedirect = 307

307 Temporary Redirect: The request should be repeated with another URI, but future requests should still use the original URI.

§

BadRequest = 400

400 Bad Request: The server could not understand the request due to invalid syntax.

§

Unauthorized = 401

401 Unauthorized: The client must authenticate itself to get the requested response.

§

PaymentRequired = 402

402 Payment Required: Reserved for future use.

§

Forbidden = 403

403 Forbidden: The client does not have access rights to the content.

§

NotFound = 404

404 Not Found: The server can not find the requested resource.

§

MethodNotAllowed = 405

405 Method Not Allowed: The request method is known by the server but is not supported by the target resource.

§

NotAcceptable = 406

406 Not Acceptable: The server cannot produce a response matching the list of acceptable values defined in the request’s headers.

§

ProxyAuthenticationRequired = 407

407 Proxy Authentication Required: The client must first authenticate itself with the proxy.

§

RequestTimeout = 408

408 Request Timeout: The server timed out waiting for the request.

§

Conflict = 409

409 Conflict: The request could not be completed due to a conflict with the current state of the resource.

§

Gone = 410

410 Gone: The resource requested is no longer available and will not be available again.

§

LengthRequired = 411

411 Length Required: The request did not specify the length of its content, which is required by the requested resource.

§

PreconditionFailed = 412

412 Precondition Failed: The server does not meet one of the preconditions that the requester put on the request.

§

RequestEntityTooLarge = 413

413 Request Entity Too Large: The request is larger than the server is willing or able to process.

§

RequestUriTooLong = 414

414 Request-URI Too Long: The URI provided was too long for the server to process.

§

UnsupportedMediaType = 415

415 Unsupported Media Type: The request entity has a media type which the server or resource does not support.

§

RequestedRangeNotSatisfiable = 416

416 Requested Range Not Satisfiable: The client has asked for a portion of the file, but the server cannot supply that portion.

§

ExpectationFailed = 417

417 Expectation Failed: The server cannot meet the requirements of the Expect request-header field.

§

InternalServerError = 500

500 Internal Server Error: The server has encountered a situation it doesn’t know how to handle.

§

NotImplemented = 501

501 Not Implemented: The request method is not supported by the server and cannot be handled.

§

BadGateway = 502

502 Bad Gateway: The server, while acting as a gateway or proxy, received an invalid response from the upstream server.

§

ServiceUnavailable = 503

503 Service Unavailable: The server is not ready to handle the request.

§

GatewayTimeout = 504

504 Gateway Timeout: The server is acting as a gateway and cannot get a response in time.

§

HttpVersionNotSupported = 505

505 HTTP Version Not Supported: The HTTP version used in the request is not supported by the server.

§

Other(u16)

Any other (unknown or non-standard) status code

Implementations§

Source§

impl StatusCode

Source

pub fn as_u16(self) -> u16

Returns the numeric status code as u16.

Source

pub fn text(self) -> &'static str

Returns the status code text.

Source

pub fn is_success(self) -> bool

Check if the status code indicates success (2xx status codes)

Source

pub fn is_client_error(self) -> bool

Check if the status code is a client error (4xx status codes)

Source

pub fn is_server_error(self) -> bool

Check if the status code is a server error (5xx status codes)

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 From<u16> for StatusCode

Source§

fn from(code: u16) -> Self

Converts to this type from the input type.
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 TryFrom<&str> for StatusCode

Source§

fn try_from(value: &str) -> Result<Self, Self::Error>

Parse a status code from a string slice.

§Examples
use nanofish::StatusCode;

let code: StatusCode = "200".try_into().unwrap();
assert_eq!(code, StatusCode::Ok);

let result: Result<StatusCode, _> = "999".try_into();
assert_eq!(result.unwrap(), StatusCode::Other(999));
Source§

type Error = Error

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

impl Copy for StatusCode

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