Struct tauri::http::status::StatusCode
x3A;:status::StatusCode,
pub struct StatusCode(_);
Expand description
An HTTP status code (status-code
in RFC 7230 et al.).
Constants are provided for known status codes, including those in the IANA HTTP Status Code Registry.
Status code values in the range 100-999 (inclusive) are supported by this type. Values in the range 100-599 are semantically classified by the most significant digit. See StatusCode::is_success
, etc. Values above 599 are unclassified but allowed for legacy compatibility, though their use is discouraged. Applications may interpret such values as protocol errors.
#
Examplesuse http::StatusCode;
assert_eq!(StatusCode::from_u16(200).unwrap(), StatusCode::OK);
assert_eq!(StatusCode::NOT_FOUND.as_u16(), 404);
assert!(StatusCode::OK.is_success());
#
ImplementationsStatusCode[src]#
implfrom_u16(src: u16) -> Result<StatusCode, InvalidStatusCode>[src]#
pub fnConverts a u16 to a status code.
The function validates the correctness of the supplied u16. It must be greater or equal to 100 and less than 1000.
#
Exampleuse http::StatusCode;
let ok = StatusCode::from_u16(200).unwrap();
assert_eq!(ok, StatusCode::OK);
let err = StatusCode::from_u16(99);
assert!(err.is_err());
from_bytes(src: &[u8]) -> Result<StatusCode, InvalidStatusCode>[src]#
pub fnConverts a &u8 to a status code
as_u16(&self) -> u16[src]#
pub fnReturns the u16
corresponding to this StatusCode
.
#
NoteThis is the same as the From<StatusCode>
implementation, but included as an inherent method because that implementation doesn’t appear in rustdocs, as well as a way to force the type instead of relying on inference.
#
Examplelet status = http::StatusCode::OK;
assert_eq!(status.as_u16(), 200);
as_str(&self) -> &str[src]#
pub fnReturns a &str representation of the StatusCode
The return value only includes a numerical representation of the status code. The canonical reason is not included.
#
Examplelet status = http::StatusCode::OK;
assert_eq!(status.as_str(), "200");
canonical_reason(&self) -> Option<<'static str>[src]#
pub fnGet the standardised reason-phrase
for this status code.
This is mostly here for servers writing responses, but could potentially have application at other times.
The reason phrase is defined as being exclusively for human readers. You should avoid deriving any meaning from it at all costs.
Bear in mind also that in HTTP/2.0 and HTTP/3.0 the reason phrase is abolished from transmission, and so this canonical reason phrase really is the only reason phrase you’ll find.
#
Examplelet status = http::StatusCode::OK;
assert_eq!(status.canonical_reason(), Some("OK"));
is_informational(&self) -> bool[src]#
pub fnCheck if status is within 100-199.
is_success(&self) -> bool[src]#
pub fnCheck if status is within 200-299.
is_redirection(&self) -> bool[src]#
pub fnCheck if status is within 300-399.
is_client_error(&self) -> bool[src]#
pub fnCheck if status is within 400-499.
is_server_error(&self) -> bool[src]#
pub fnCheck if status is within 500-599.
StatusCode[src]#
implCONTINUE: StatusCode[src]#
pub const100 Continue [RFC7231, Section 6.2.1]
SWITCHING_PROTOCOLS: StatusCode[src]#
pub const101 Switching Protocols [RFC7231, Section 6.2.2]
PROCESSING: StatusCode[src]#
pub const102 Processing [RFC2518]
OK: StatusCode[src]#
pub const200 OK [RFC7231, Section 6.3.1]
CREATED: StatusCode[src]#
pub const201 Created [RFC7231, Section 6.3.2]
ACCEPTED: StatusCode[src]#
pub const202 Accepted [RFC7231, Section 6.3.3]
NON_AUTHORITATIVE_INFORMATION: StatusCode[src]#
pub const203 Non-Authoritative Information [RFC7231, Section 6.3.4]
NO_CONTENT: StatusCode[src]#
pub const204 No Content [RFC7231, Section 6.3.5]
RESET_CONTENT: StatusCode[src]#
pub const205 Reset Content [RFC7231, Section 6.3.6]
PARTIAL_CONTENT: StatusCode[src]#
pub const206 Partial Content [RFC7233, Section 4.1]
MULTI_STATUS: StatusCode[src]#
pub const207 Multi-Status [RFC4918]
ALREADY_REPORTED: StatusCode[src]#
pub const208 Already Reported [RFC5842]
IM_USED: StatusCode[src]#
pub const226 IM Used [RFC3229]
MULTIPLE_CHOICES: StatusCode[src]#
pub const300 Multiple Choices [RFC7231, Section 6.4.1]
MOVED_PERMANENTLY: StatusCode[src]#
pub const301 Moved Permanently [RFC7231, Section 6.4.2]
FOUND: StatusCode[src]#
pub const302 Found [RFC7231, Section 6.4.3]
SEE_OTHER: StatusCode[src]#
pub const303 See Other [RFC7231, Section 6.4.4]
NOT_MODIFIED: StatusCode[src]#
pub const304 Not Modified [RFC7232, Section 4.1]
USE_PROXY: StatusCode[src]#
pub const305 Use Proxy [RFC7231, Section 6.4.5]
TEMPORARY_REDIRECT: StatusCode[src]#
pub const307 Temporary Redirect [RFC7231, Section 6.4.7]
PERMANENT_REDIRECT: StatusCode[src]#
pub const308 Permanent Redirect [RFC7238]
BAD_REQUEST: StatusCode[src]#
pub const400 Bad Request [RFC7231, Section 6.5.1]
UNAUTHORIZED: StatusCode[src]#
pub const401 Unauthorized [RFC7235, Section 3.1]
PAYMENT_REQUIRED: StatusCode[src]#
pub const402 Payment Required [RFC7231, Section 6.5.2]
FORBIDDEN: StatusCode[src]#
pub const403 Forbidden [RFC7231, Section 6.5.3]
NOT_FOUND: StatusCode[src]#
pub const404 Not Found [RFC7231, Section 6.5.4]
METHOD_NOT_ALLOWED: StatusCode[src]#
pub const405 Method Not Allowed [RFC7231, Section 6.5.5]
NOT_ACCEPTABLE: StatusCode[src]#
pub const406 Not Acceptable [RFC7231, Section 6.5.6]
PROXY_AUTHENTICATION_REQUIRED: StatusCode[src]#
pub const407 Proxy Authentication Required [RFC7235, Section 3.2]
REQUEST_TIMEOUT: StatusCode[src]#
pub const408 Request Timeout [RFC7231, Section 6.5.7]
CONFLICT: StatusCode[src]#
pub const409 Conflict [RFC7231, Section 6.5.8]
GONE: StatusCode[src]#
pub const410 Gone [RFC7231, Section 6.5.9]
LENGTH_REQUIRED: StatusCode[src]#
pub const411 Length Required [RFC7231, Section 6.5.10]
PRECONDITION_FAILED: StatusCode[src]#
pub const412 Precondition Failed [RFC7232, Section 4.2]
PAYLOAD_TOO_LARGE: StatusCode[src]#
pub const413 Payload Too Large [RFC7231, Section 6.5.11]
URI_TOO_LONG: StatusCode[src]#
pub const414 URI Too Long [RFC7231, Section 6.5.12]
UNSUPPORTED_MEDIA_TYPE: StatusCode[src]#
pub const415 Unsupported Media Type [RFC7231, Section 6.5.13]
RANGE_NOT_SATISFIABLE: StatusCode[src]#
pub const416 Range Not Satisfiable [RFC7233, Section 4.4]
EXPECTATION_FAILED: StatusCode[src]#
pub const417 Expectation Failed [RFC7231, Section 6.5.14]
IM_A_TEAPOT: StatusCode[src]#
pub const418 I’m a teapot [curiously not registered by IANA but RFC2324]
MISDIRECTED_REQUEST: StatusCode[src]#
pub const421 Misdirected Request RFC7540, Section 9.1.2
UNPROCESSABLE_ENTITY: StatusCode[src]#
pub const422 Unprocessable Entity [RFC4918]
LOCKED: StatusCode[src]#
pub const423 Locked [RFC4918]
FAILED_DEPENDENCY: StatusCode[src]#
pub const424 Failed Dependency [RFC4918]
UPGRADE_REQUIRED: StatusCode[src]#
pub const426 Upgrade Required [RFC7231, Section 6.5.15]
PRECONDITION_REQUIRED: StatusCode[src]#
pub const428 Precondition Required [RFC6585]
TOO_MANY_REQUESTS: StatusCode[src]#
pub const429 Too Many Requests [RFC6585]
REQUEST_HEADER_FIELDS_TOO_LARGE: StatusCode[src]#
pub const431 Request Header Fields Too Large [RFC6585]
UNAVAILABLE_FOR_LEGAL_REASONS: StatusCode[src]#
pub const451 Unavailable For Legal Reasons [RFC7725]
INTERNAL_SERVER_ERROR: StatusCode[src]#
pub const500 Internal Server Error [RFC7231, Section 6.6.1]
NOT_IMPLEMENTED: StatusCode[src]#
pub const501 Not Implemented [RFC7231, Section 6.6.2]
BAD_GATEWAY: StatusCode[src]#
pub const502 Bad Gateway [RFC7231, Section 6.6.3]
SERVICE_UNAVAILABLE: StatusCode[src]#
pub const503 Service Unavailable [RFC7231, Section 6.6.4]
GATEWAY_TIMEOUT: StatusCode[src]#
pub const504 Gateway Timeout [RFC7231, Section 6.6.5]
HTTP_VERSION_NOT_SUPPORTED: StatusCode[src]#
pub const505 HTTP Version Not Supported [RFC7231, Section 6.6.6]
VARIANT_ALSO_NEGOTIATES: StatusCode[src]#
pub const506 Variant Also Negotiates [RFC2295]
INSUFFICIENT_STORAGE: StatusCode[src]#
pub const507 Insufficient Storage [RFC4918]
LOOP_DETECTED: StatusCode[src]#
pub const508 Loop Detected [RFC5842]
NOT_EXTENDED: StatusCode[src]#
pub const510 Not Extended [RFC2774]
NETWORK_AUTHENTICATION_REQUIRED: StatusCode[src]#
pub const511 Network Authentication Required [RFC6585]
#
Trait ImplementationsClone for StatusCode[src]#
implclone(&self) -> StatusCode[src]#
pub fnReturns a copy of the value. Read more
clone_from(&mut self, source: &Self)1.0.0[src]#
fnPerforms copy-assignment from source
. Read more
Debug for StatusCode[src]#
implfmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]#
pub fnFormats the value using the given formatter. Read more
Default for StatusCode[src]#
impldefault() -> StatusCode[src]#
pub fnReturns the “default value” for a type. Read more
Display for StatusCode[src]#
implFormats the status code, including the canonical reason.
#
Exampleassert_eq!(format!("{}", StatusCode::OK), "200 OK");
fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]#
pub fnFormats the value using the given formatter. Read more
From<<'a StatusCode> for StatusCode[src]#
impl<'a>from(t: &'a StatusCode) -> StatusCode[src]#
pub fnPerforms the conversion.
FromStr for StatusCode[src]#
implErr = InvalidStatusCode#
typeThe associated error which can be returned from parsing.
from_str(s: &str) -> Result<StatusCode, InvalidStatusCode>[src]#
pub fnParses a string s
to return a value of this type. Read more
Hash for StatusCode[src]#
implhash<__H>(&self, state: &mut__H) where __H: Hasher,[src]#
pub fnFeeds this value into the given Hasher
. Read more
hash_slice<H>(data: &[Self], state: &mutH) where H: Hasher,1.3.0[src]#
fnFeeds a slice of this type into the given Hasher
. Read more
Ord for StatusCode[src]#
implcmp(&self, other: &StatusCode) -> Ordering[src]#
pub fnThis method returns an Ordering
between self
and other
. Read more
max(self, other: Self) -> Self1.21.0[src]#
#[must_use]fnCompares and returns the maximum of two values. Read more
min(self, other: Self) -> Self1.21.0[src]#
#[must_use]fnCompares and returns the minimum of two values. Read more
clamp(self, min: Self, max: Self) -> Self1.50.0[src]#
#[must_use]fnRestrict a value to a certain interval. Read more
PartialEq<StatusCode> for StatusCode[src]#
impleq(&self, other: &StatusCode) -> bool[src]#
pub fnThis method tests for self
and other
values to be equal, and is used by ==
. Read more
ne(&self, other: &StatusCode) -> bool[src]#
pub fnThis method tests for !=
.
PartialEq<u16> for StatusCode[src]#
impleq(&self, other: &u16) -> bool[src]#
pub fnThis method tests for self
and other
values to be equal, and is used by ==
. Read more
ne(&self, other: &Rhs) -> bool1.0.0[src]#
#[must_use]fnThis method tests for !=
.
PartialOrd<StatusCode> for StatusCode[src]#
implpartial_cmp(&self, other: &StatusCode) -> Option<Ordering>[src]#
pub fnThis method returns an ordering between self
and other
values if one exists. Read more
lt(&self, other: &Rhs) -> bool1.0.0[src]#
#[must_use]fnThis method tests less than (for self
and other
) and is used by the <
operator. Read more
le(&self, other: &Rhs) -> bool1.0.0[src]#
#[must_use]fnThis method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
gt(&self, other: &Rhs) -> bool1.0.0[src]#
#[must_use]fnThis method tests greater than (for self
and other
) and is used by the >
operator. Read more
ge(&self, other: &Rhs) -> bool1.0.0[src]#
#[must_use]fnThis method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
TryFrom<&'a [u8]> for StatusCode[src]#
impl<'a>Error = InvalidStatusCode#
typeThe type returned in the event of a conversion error.
try_from( t: &'a [u8] ) -> Result<StatusCode, <StatusCode as TryFrom<&'a [u8]>>::Error>[src]#
pub fnPerforms the conversion.
TryFrom<<'a str> for StatusCode[src]#
impl<'a>Error = InvalidStatusCode#
typeThe type returned in the event of a conversion error.
try_from( t: &'a str ) -> Result<StatusCode, <StatusCode as TryFrom<<'a str>>::Error>[src]#
pub fnPerforms the conversion.
TryFrom<u16> for StatusCode[src]#
implError = InvalidStatusCode#
typeThe type returned in the event of a conversion error.
try_from( t: u16 ) -> Result<StatusCode, <StatusCode as TryFrom<u16>>::Error>[src]#
pub fnPerforms the conversion.
Copy for StatusCode#
implEq for StatusCode#
implStructuralEq for StatusCode#
implStructuralPartialEq for StatusCode#
impl#
Auto Trait ImplementationsRefUnwindSafe for StatusCode#
implSend for StatusCode#
implSync for StatusCode#
implUnpin for StatusCode#
implUnwindSafe for StatusCode#
impl#
Blanket ImplementationsAny for T where T: 'static + ?Sized,[src]#
impl<T>type_id(&self) -> TypeId[src]#
pub fnGets the TypeId
of self
. Read more
Borrow<T> for T where T: ?Sized,[src]#
impl<T>borrow(&self) -> &T[src]#
pub fnImmutably borrows from an owned value. Read more
BorrowMut<T> for T where T: ?Sized,[src]#
impl<T>borrow_mut(&mut self) -> &mutT[src]#
pub fnMutably borrows from an owned value. Read more
From<T> for T[src]#
impl<T>from(t: T) -> T[src]#
pub fnPerforms the conversion.
Into<U> for T where U: From<T>,[src]#
impl<T, U>into(self) -> U[src]#
pub fnPerforms the conversion.
ToOwned for T where T: Clone,[src]#
impl<T>Owned = T#
typeThe resulting type after obtaining ownership.
to_owned(&self) -> T[src]#
pub fnCreates owned data from borrowed data, usually by cloning. Read more
clone_into(&self, target: &mutT)[src]#
pub fn🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
ToString for T where T: Display + ?Sized,[src]#
impl<T>to_string(&self) -> String[src]#
pub default fnConverts the given value to a String
. Read more
TryFrom<U> for T where U: Into<T>,[src]#
impl<T, U>Error = Infallible#
typeThe type returned in the event of a conversion error.
try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]#
pub fnPerforms the conversion.
TryInto<U> for T where U: TryFrom<T>,[src]#
impl<T, U>Error = <U as TryFrom<T>>::Error#
typeThe type returned in the event of a conversion error.
try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]#
pub fnPerforms the conversion.