[−][src]Struct rocket_http::Status
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 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: u16The HTTP status code associated with this status.
reason: &'static strThe HTTP reason phrase associated with this status.
Methods
impl Status[src]
pub fn new(code: u16, reason: &'static str) -> Status[src]
Creates a new Status with code and reason. This should be used 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]
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[src]
Status with code
100
and reason
Continue
.
pub const SwitchingProtocols: Status[src]
Status with code
101
and reason
Switching Protocols
.
pub const Processing: Status[src]
Status with code
102
and reason
Processing
.
pub const Ok: Status[src]
Status with code
200
and reason
OK
.
pub const Created: Status[src]
Status with code
201
and reason
Created
.
pub const Accepted: Status[src]
Status with code
202
and reason
Accepted
.
pub const NonAuthoritativeInformation: Status[src]
Status with code
203
and reason
Non-Authoritative Information
.
pub const NoContent: Status[src]
Status with code
204
and reason
No Content
.
pub const ResetContent: Status[src]
Status with code
205
and reason
Reset Content
.
pub const PartialContent: Status[src]
Status with code
206
and reason
Partial Content
.
pub const MultiStatus: Status[src]
Status with code
207
and reason
Multi-Status
.
pub const AlreadyReported: Status[src]
Status with code
208
and reason
Already Reported
.
pub const ImUsed: Status[src]
Status with code
226
and reason
IM Used
.
pub const MultipleChoices: Status[src]
Status with code
300
and reason
Multiple Choices
.
pub const MovedPermanently: Status[src]
Status with code
301
and reason
Moved Permanently
.
pub const Found: Status[src]
Status with code
302
and reason
Found
.
pub const SeeOther: Status[src]
Status with code
303
and reason
See Other
.
pub const NotModified: Status[src]
Status with code
304
and reason
Not Modified
.
pub const UseProxy: Status[src]
Status with code
305
and reason
Use Proxy
.
pub const TemporaryRedirect: Status[src]
Status with code
307
and reason
Temporary Redirect
.
pub const PermanentRedirect: Status[src]
Status with code
308
and reason
Permanent Redirect
.
pub const BadRequest: Status[src]
Status with code
400
and reason
Bad Request
.
pub const Unauthorized: Status[src]
Status with code
401
and reason
Unauthorized
.
pub const PaymentRequired: Status[src]
Status with code
402
and reason
Payment Required
.
pub const Forbidden: Status[src]
Status with code
403
and reason
Forbidden
.
pub const NotFound: Status[src]
Status with code
404
and reason
Not Found
.
pub const MethodNotAllowed: Status[src]
Status with code
405
and reason
Method Not Allowed
.
pub const NotAcceptable: Status[src]
Status with code
406
and reason
Not Acceptable
.
pub const ProxyAuthenticationRequired: Status[src]
Status with code
407
and reason
Proxy Authentication Required
.
pub const RequestTimeout: Status[src]
Status with code
408
and reason
Request Timeout
.
pub const Conflict: Status[src]
Status with code
409
and reason
Conflict
.
pub const Gone: Status[src]
Status with code
410
and reason
Gone
.
pub const LengthRequired: Status[src]
Status with code
411
and reason
Length Required
.
pub const PreconditionFailed: Status[src]
Status with code
412
and reason
Precondition Failed
.
pub const PayloadTooLarge: Status[src]
Status with code
413
and reason
Payload Too Large
.
pub const UriTooLong: Status[src]
Status with code
414
and reason
URI Too Long
.
pub const UnsupportedMediaType: Status[src]
Status with code
415
and reason
Unsupported Media Type
.
pub const RangeNotSatisfiable: Status[src]
Status with code
416
and reason
Range Not Satisfiable
.
pub const ExpectationFailed: Status[src]
Status with code
417
and reason
Expectation Failed
.
pub const ImATeapot: Status[src]
Status with code
418
and reason
I'm a teapot
.
pub const MisdirectedRequest: Status[src]
Status with code
421
and reason
Misdirected Request
.
pub const UnprocessableEntity: Status[src]
Status with code
422
and reason
Unprocessable Entity
.
pub const Locked: Status[src]
Status with code
423
and reason
Locked
.
pub const FailedDependency: Status[src]
Status with code
424
and reason
Failed Dependency
.
pub const UpgradeRequired: Status[src]
Status with code
426
and reason
Upgrade Required
.
pub const PreconditionRequired: Status[src]
Status with code
428
and reason
Precondition Required
.
pub const TooManyRequests: Status[src]
Status with code
429
and reason
Too Many Requests
.
pub const RequestHeaderFieldsTooLarge: Status[src]
Status with code
431
and reason
Request Header Fields Too Large
.
pub const UnavailableForLegalReasons: Status[src]
Status with code
451
and reason
Unavailable For Legal Reasons
.
pub const InternalServerError: Status[src]
Status with code
500
and reason
Internal Server Error
.
pub const NotImplemented: Status[src]
Status with code
501
and reason
Not Implemented
.
pub const BadGateway: Status[src]
Status with code
502
and reason
Bad Gateway
.
pub const ServiceUnavailable: Status[src]
Status with code
503
and reason
Service Unavailable
.
pub const GatewayTimeout: Status[src]
Status with code
504
and reason
Gateway Timeout
.
pub const HttpVersionNotSupported: Status[src]
Status with code
505
and reason
HTTP Version Not Supported
.
pub const VariantAlsoNegotiates: Status[src]
Status with code
506
and reason
Variant Also Negotiates
.
pub const InsufficientStorage: Status[src]
Status with code
507
and reason
Insufficient Storage
.
pub const LoopDetected: Status[src]
Status with code
508
and reason
Loop Detected
.
pub const NotExtended: Status[src]
Status with code
510
and reason
Not Extended
.
pub const NetworkAuthenticationRequired: Status[src]
Status with code
511
and reason
Network Authentication Required
.
pub fn from_code(code: u16) -> Option<Status>[src]
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 Clone for Status[src]
impl Copy for Status[src]
impl Debug for Status[src]
impl Display for Status[src]
impl Eq for Status[src]
impl Hash for Status[src]
fn hash<__H: Hasher>(&self, state: &mut __H)[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
impl PartialEq<Status> for Status[src]
impl StructuralEq for Status[src]
impl StructuralPartialEq for Status[src]
Auto Trait Implementations
impl RefUnwindSafe for Status
impl Send for Status
impl Sync for Status
impl Unpin for Status
impl UnwindSafe for Status
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T, I> AsResult<T, I> for T where
I: Input, [src]
I: Input,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized, [src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
fn equivalent(&self, key: &K) -> bool[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> IntoCollection<T> for T[src]
fn into_collection<A>(Self) -> SmallVec<A> where
A: Array<Item = T>, [src]
A: Array<Item = T>,
fn mapped<U, F, A>(Self, F) -> SmallVec<A> where
A: Array<Item = U>,
F: FnMut(T) -> U, [src]
A: Array<Item = U>,
F: FnMut(T) -> U,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T> ToString for T where
T: Display + ?Sized, [src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T> Typeable for T where
T: Any, [src]
T: Any,