Struct rocket::http::Status [−][src]
Structure representing an HTTP status: an integer code and a reason phrase.
Usage
Status classes should rarely be created directly. Instead, an associated constant should be used; one is declared for every standard status defined in the HTTP standard.
Example
A status of 200 OK
can be instantiated via the Ok
constant:
use rocket::http::Status; let ok = Status::Ok;
A status of 404 Not Found
can be instantiated via the NotFound
constant:
use rocket::http::Status; let not_found = Status::NotFound;
The code and phrase can be retrieved directly:
use rocket::http::Status; let not_found = Status::NotFound; assert_eq!(not_found.code, 404); assert_eq!(not_found.reason, "Not Found"); assert_eq!(not_found.to_string(), "404 Not Found".to_string());
Fields
code: u16
The HTTP status code associated with this status.
reason: &'static str
The HTTP reason phrase associated with this status.
Methods
impl Status
[src]
impl Status
pub const fn new(code: u16, reason: &'static str) -> Status
[src]
pub const fn new(code: u16, reason: &'static str) -> Status
Creates a new Status
with code
and reason
. This should be only
to construct non-standard HTTP statuses. Use an associated constant for
standard statuses.
Example
Create a custom 299 Somewhat Successful
status:
use rocket::http::Status; let custom = Status::new(299, "Somewhat Successful"); assert_eq!(custom.to_string(), "299 Somewhat Successful".to_string());
pub fn class(&self) -> StatusClass
[src]
pub fn class(&self) -> StatusClass
Returns the class of a given status.
Example
use rocket::http::{Status, StatusClass}; let processing = Status::Processing; assert_eq!(processing.class(), StatusClass::Informational); let ok = Status::Ok; assert_eq!(ok.class(), StatusClass::Success); let see_other = Status::SeeOther; assert_eq!(see_other.class(), StatusClass::Redirection); let not_found = Status::NotFound; assert_eq!(not_found.class(), StatusClass::ClientError); let internal_error = Status::InternalServerError; assert_eq!(internal_error.class(), StatusClass::ServerError); let custom = Status::new(600, "Bizarre"); assert_eq!(custom.class(), StatusClass::Unknown);
pub const Continue: Status
Continue: Status = <Status>::new(100, "Continue")
Status with code 100 and reason Continue .
pub const SwitchingProtocols: Status
SwitchingProtocols: Status = <Status>::new(101, "Switching Protocols")
Status with code 101 and reason Switching Protocols .
pub const Processing: Status
Processing: Status = <Status>::new(102, "Processing")
Status with code 102 and reason Processing .
pub const Ok: Status
Ok: Status = <Status>::new(200, "OK")
Status with code 200 and reason OK .
pub const Created: Status
Created: Status = <Status>::new(201, "Created")
Status with code 201 and reason Created .
pub const Accepted: Status
Accepted: Status = <Status>::new(202, "Accepted")
Status with code 202 and reason Accepted .
pub const NonAuthoritativeInformation: Status
NonAuthoritativeInformation: Status = <Status>::new(203, "Non-Authoritative Information")
Status with code 203 and reason Non-Authoritative Information .
pub const NoContent: Status
NoContent: Status = <Status>::new(204, "No Content")
Status with code 204 and reason No Content .
pub const ResetContent: Status
ResetContent: Status = <Status>::new(205, "Reset Content")
Status with code 205 and reason Reset Content .
pub const PartialContent: Status
PartialContent: Status = <Status>::new(206, "Partial Content")
Status with code 206 and reason Partial Content .
pub const MultiStatus: Status
MultiStatus: Status = <Status>::new(207, "Multi-Status")
Status with code 207 and reason Multi-Status .
pub const AlreadyReported: Status
AlreadyReported: Status = <Status>::new(208, "Already Reported")
Status with code 208 and reason Already Reported .
pub const ImUsed: Status
ImUsed: Status = <Status>::new(226, "IM Used")
Status with code 226 and reason IM Used .
pub const MultipleChoices: Status
MultipleChoices: Status = <Status>::new(300, "Multiple Choices")
Status with code 300 and reason Multiple Choices .
pub const MovedPermanently: Status
MovedPermanently: Status = <Status>::new(301, "Moved Permanently")
Status with code 301 and reason Moved Permanently .
pub const Found: Status
Found: Status = <Status>::new(302, "Found")
Status with code 302 and reason Found .
pub const SeeOther: Status
SeeOther: Status = <Status>::new(303, "See Other")
Status with code 303 and reason See Other .
pub const NotModified: Status
NotModified: Status = <Status>::new(304, "Not Modified")
Status with code 304 and reason Not Modified .
pub const UseProxy: Status
UseProxy: Status = <Status>::new(305, "Use Proxy")
Status with code 305 and reason Use Proxy .
pub const TemporaryRedirect: Status
TemporaryRedirect: Status = <Status>::new(307, "Temporary Redirect")
Status with code 307 and reason Temporary Redirect .
pub const PermanentRedirect: Status
PermanentRedirect: Status = <Status>::new(308, "Permanent Redirect")
Status with code 308 and reason Permanent Redirect .
pub const BadRequest: Status
BadRequest: Status = <Status>::new(400, "Bad Request")
Status with code 400 and reason Bad Request .
Unauthorized: Status = <Status>::new(401, "Unauthorized")
Status with code 401 and reason Unauthorized .
pub const PaymentRequired: Status
PaymentRequired: Status = <Status>::new(402, "Payment Required")
Status with code 402 and reason Payment Required .
pub const Forbidden: Status
Forbidden: Status = <Status>::new(403, "Forbidden")
Status with code 403 and reason Forbidden .
pub const NotFound: Status
NotFound: Status = <Status>::new(404, "Not Found")
Status with code 404 and reason Not Found .
pub const MethodNotAllowed: Status
MethodNotAllowed: Status = <Status>::new(405, "Method Not Allowed")
Status with code 405 and reason Method Not Allowed .
pub const NotAcceptable: Status
NotAcceptable: Status = <Status>::new(406, "Not Acceptable")
Status with code 406 and reason Not Acceptable .
pub const ProxyAuthenticationRequired: Status
ProxyAuthenticationRequired: Status = <Status>::new(407, "Proxy Authentication Required")
Status with code 407 and reason Proxy Authentication Required .
pub const RequestTimeout: Status
RequestTimeout: Status = <Status>::new(408, "Request Timeout")
Status with code 408 and reason Request Timeout .
pub const Conflict: Status
Conflict: Status = <Status>::new(409, "Conflict")
Status with code 409 and reason Conflict .
pub const Gone: Status
Gone: Status = <Status>::new(410, "Gone")
Status with code 410 and reason Gone .
pub const LengthRequired: Status
LengthRequired: Status = <Status>::new(411, "Length Required")
Status with code 411 and reason Length Required .
pub const PreconditionFailed: Status
PreconditionFailed: Status = <Status>::new(412, "Precondition Failed")
Status with code 412 and reason Precondition Failed .
pub const PayloadTooLarge: Status
PayloadTooLarge: Status = <Status>::new(413, "Payload Too Large")
Status with code 413 and reason Payload Too Large .
pub const UriTooLong: Status
UriTooLong: Status = <Status>::new(414, "URI Too Long")
Status with code 414 and reason URI Too Long .
pub const UnsupportedMediaType: Status
UnsupportedMediaType: Status = <Status>::new(415, "Unsupported Media Type")
Status with code 415 and reason Unsupported Media Type .
pub const RangeNotSatisfiable: Status
RangeNotSatisfiable: Status = <Status>::new(416, "Range Not Satisfiable")
Status with code 416 and reason Range Not Satisfiable .
pub const ExpectationFailed: Status
ExpectationFailed: Status = <Status>::new(417, "Expectation Failed")
Status with code 417 and reason Expectation Failed .
pub const ImATeapot: Status
ImATeapot: Status = <Status>::new(418, "I\'m a teapot")
Status with code 418 and reason I'm a teapot .
pub const MisdirectedRequest: Status
MisdirectedRequest: Status = <Status>::new(421, "Misdirected Request")
Status with code 421 and reason Misdirected Request .
pub const UnprocessableEntity: Status
UnprocessableEntity: Status = <Status>::new(422, "Unprocessable Entity")
Status with code 422 and reason Unprocessable Entity .
pub const Locked: Status
Locked: Status = <Status>::new(423, "Locked")
Status with code 423 and reason Locked .
pub const FailedDependency: Status
FailedDependency: Status = <Status>::new(424, "Failed Dependency")
Status with code 424 and reason Failed Dependency .
pub const UpgradeRequired: Status
UpgradeRequired: Status = <Status>::new(426, "Upgrade Required")
Status with code 426 and reason Upgrade Required .
pub const PreconditionRequired: Status
PreconditionRequired: Status = <Status>::new(428, "Precondition Required")
Status with code 428 and reason Precondition Required .
pub const TooManyRequests: Status
TooManyRequests: Status = <Status>::new(429, "Too Many Requests")
Status with code 429 and reason Too Many Requests .
pub const RequestHeaderFieldsTooLarge: Status
RequestHeaderFieldsTooLarge: Status = <Status>::new(431, "Request Header Fields Too Large")
Status with code 431 and reason Request Header Fields Too Large .
UnavailableForLegalReasons: Status = <Status>::new(451, "Unavailable For Legal Reasons")
Status with code 451 and reason Unavailable For Legal Reasons .
pub const InternalServerError: Status
InternalServerError: Status = <Status>::new(500, "Internal Server Error")
Status with code 500 and reason Internal Server Error .
pub const NotImplemented: Status
NotImplemented: Status = <Status>::new(501, "Not Implemented")
Status with code 501 and reason Not Implemented .
pub const BadGateway: Status
BadGateway: Status = <Status>::new(502, "Bad Gateway")
Status with code 502 and reason Bad Gateway .
ServiceUnavailable: Status = <Status>::new(503, "Service Unavailable")
Status with code 503 and reason Service Unavailable .
pub const GatewayTimeout: Status
GatewayTimeout: Status = <Status>::new(504, "Gateway Timeout")
Status with code 504 and reason Gateway Timeout .
pub const HttpVersionNotSupported: Status
HttpVersionNotSupported: Status = <Status>::new(505, "HTTP Version Not Supported")
Status with code 505 and reason HTTP Version Not Supported .
pub const VariantAlsoNegotiates: Status
VariantAlsoNegotiates: Status = <Status>::new(506, "Variant Also Negotiates")
Status with code 506 and reason Variant Also Negotiates .
pub const InsufficientStorage: Status
InsufficientStorage: Status = <Status>::new(507, "Insufficient Storage")
Status with code 507 and reason Insufficient Storage .
pub const LoopDetected: Status
LoopDetected: Status = <Status>::new(508, "Loop Detected")
Status with code 508 and reason Loop Detected .
pub const NotExtended: Status
NotExtended: Status = <Status>::new(510, "Not Extended")
Status with code 510 and reason Not Extended .
pub const NetworkAuthenticationRequired: Status
NetworkAuthenticationRequired: Status = <Status>::new(511, "Network Authentication Required")
Status with code 511 and reason Network Authentication Required .
pub fn from_code(code: u16) -> Option<Status>
[src]
pub fn from_code(code: u16) -> Option<Status>
Returns a Status given a standard status code code
. If code
is
not a known status code, None
is returned.
Example
Create a Status
from a known code
:
use rocket::http::Status; let not_found = Status::from_code(404); assert_eq!(not_found, Some(Status::NotFound));
Create a Status
from an unknown code
:
use rocket::http::Status; let not_found = Status::from_code(600); assert!(not_found.is_none());
Trait Implementations
impl Debug for Status
[src]
impl Debug for Status
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Clone for Status
[src]
impl Clone for Status
fn clone(&self) -> Status
[src]
fn clone(&self) -> Status
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Copy for Status
[src]
impl Copy for Status
impl Hash for Status
[src]
impl Hash for Status
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl PartialEq for Status
[src]
impl PartialEq for Status
fn eq(&self, other: &Status) -> bool
[src]
fn eq(&self, other: &Status) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Status) -> bool
[src]
fn ne(&self, other: &Status) -> bool
This method tests for !=
.
impl Eq for Status
[src]
impl Eq for Status
impl Display for Status
[src]
impl Display for Status
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl From<Status> for Failure
[src]
impl From<Status> for Failure