An HTTP status code.
Methods
Returns the u16
corresponding to this StatusCode
.
Note
This 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.
Example
use StatusCode;
let status = OK;
assert_eq!;
Returns a &str representation of the StatusCode
The return value only includes a numerical representation of the status code. The canonical reason is not included.
Example
use StatusCode;
let status = OK;
assert_eq!;
Get 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.
Example
use StatusCode;
let status = OK;
assert_eq!;
Check if status is within 100-199.
Check if status is within 200-299.
Check if status is within 300-399.
Check if status is within 400-499.
Check if status is within 500-599.
Trait Implementations
Compare two values for equality.
Examples
assert_eq!;
assert_eq!;
assert_eq!;
Compare two values for inequality.
Examples
assert_eq!;
assert_eq!;
assert_eq!;
Compare two values.
Examples
use Ordering;
assert_eq!;
assert_eq!;
assert_eq!;
Tests less than (for self
and other
) and is used by the <
operator.
Examples
assert_eq!;
assert_eq!;
assert_eq!;
Tests less than or equal to (for self
and other
) and is used by the <=
operator.
Examples
assert_eq!;
assert_eq!;
assert_eq!;
Tests greater than (for self
and other
) and is used by the >
operator.
Examples
assert_eq!;
assert_eq!;
assert_eq!;
Tests greater than or equal to (for self
and other
) and is used by the >=
operator.
Examples
assert_eq!;
assert_eq!;
assert_eq!;
Compare two values.
Examples
use Ordering;
assert_eq!;
assert_eq!;
assert_eq!;
Return the minimum of two values.
Examples
assert_eq!;
assert_eq!;
assert_eq!;
Return the maximum of two values.
Examples
assert_eq!;
assert_eq!;
assert_eq!;
Protocols
if value == b
Test two status codes for partial equality.
Examples
use partial_eq;
use StatusCode;
let ok = OK;
let not_found = NOT_FOUND;
assert_eq!;
assert_eq!;
assert_eq!;
if value == b
Test two status codes for total equality.
Examples
use eq;
use StatusCode;
let ok = OK;
let not_found = NOT_FOUND;
assert_eq!;
assert_eq!;
assert_eq!;
if value < b
Perform a partial ordered comparison between two status codes.
Examples
use StatusCode;
let ok = OK;
let not_found = NOT_FOUND;
assert!;
assert!;
assert!;
Using explicit functions:
use Ordering;
use partial_cmp;
use StatusCode;
let ok = OK;
let not_found = NOT_FOUND;
assert_eq!;
assert_eq!;
assert_eq!;
if value < b
Perform a totally ordered comparison between two status codes.
Examples
use Ordering;
use cmp;
use StatusCode;
let ok = OK;
let not_found = NOT_FOUND;
assert_eq!;
assert_eq!;
assert_eq!;
let $out = hash
Hash the status code.
Examples
use hash;
use StatusCode;
let not_found = NOT_FOUND;
assert_eq!;
format!
Write a debug representation of the status code.
Examples
use StatusCode;
let not_found = NOT_FOUND;
println!;
format!
Write a display representation of the status code.
Examples
use StatusCode;
let not_found = NOT_FOUND;
println!;