Enum hyper::status::StatusCode
[-]
[+]
[src]
pub enum StatusCode { Continue, SwitchingProtocols, Processing, Code103, Code104, Code105, Code106, Code107, Code108, Code109, Code110, Code111, Code112, Code113, Code114, Code115, Code116, Code117, Code118, Code119, Code120, Code121, Code122, Code123, Code124, Code125, Code126, Code127, Code128, Code129, Code130, Code131, Code132, Code133, Code134, Code135, Code136, Code137, Code138, Code139, Code140, Code141, Code142, Code143, Code144, Code145, Code146, Code147, Code148, Code149, Code150, Code151, Code152, Code153, Code154, Code155, Code156, Code157, Code158, Code159, Code160, Code161, Code162, Code163, Code164, Code165, Code166, Code167, Code168, Code169, Code170, Code171, Code172, Code173, Code174, Code175, Code176, Code177, Code178, Code179, Code180, Code181, Code182, Code183, Code184, Code185, Code186, Code187, Code188, Code189, Code190, Code191, Code192, Code193, Code194, Code195, Code196, Code197, Code198, Code199, Ok, Created, Accepted, NonAuthoritativeInformation, NoContent, ResetContent, PartialContent, MultiStatus, AlreadyReported, Code209, Code210, Code211, Code212, Code213, Code214, Code215, Code216, Code217, Code218, Code219, Code220, Code221, Code222, Code223, Code224, Code225, ImUsed, Code227, Code228, Code229, Code230, Code231, Code232, Code233, Code234, Code235, Code236, Code237, Code238, Code239, Code240, Code241, Code242, Code243, Code244, Code245, Code246, Code247, Code248, Code249, Code250, Code251, Code252, Code253, Code254, Code255, Code256, Code257, Code258, Code259, Code260, Code261, Code262, Code263, Code264, Code265, Code266, Code267, Code268, Code269, Code270, Code271, Code272, Code273, Code274, Code275, Code276, Code277, Code278, Code279, Code280, Code281, Code282, Code283, Code284, Code285, Code286, Code287, Code288, Code289, Code290, Code291, Code292, Code293, Code294, Code295, Code296, Code297, Code298, Code299, MultipleChoices, MovedPermanently, Found, SeeOther, NotModified, UseProxy, SwitchProxy, TemporaryRedirect, PermanentRedirect, Code309, Code310, Code311, Code312, Code313, Code314, Code315, Code316, Code317, Code318, Code319, Code320, Code321, Code322, Code323, Code324, Code325, Code326, Code327, Code328, Code329, Code330, Code331, Code332, Code333, Code334, Code335, Code336, Code337, Code338, Code339, Code340, Code341, Code342, Code343, Code344, Code345, Code346, Code347, Code348, Code349, Code350, Code351, Code352, Code353, Code354, Code355, Code356, Code357, Code358, Code359, Code360, Code361, Code362, Code363, Code364, Code365, Code366, Code367, Code368, Code369, Code370, Code371, Code372, Code373, Code374, Code375, Code376, Code377, Code378, Code379, Code380, Code381, Code382, Code383, Code384, Code385, Code386, Code387, Code388, Code389, Code390, Code391, Code392, Code393, Code394, Code395, Code396, Code397, Code398, Code399, BadRequest, Unauthorized, PaymentRequired, Forbidden, NotFound, MethodNotAllowed, NotAcceptable, ProxyAuthenticationRequired, RequestTimeout, Conflict, Gone, LengthRequired, PreconditionFailed, RequestEntityTooLarge, RequestUriTooLong, UnsupportedMediaType, RequestedRangeNotSatisfiable, ExpectationFailed, ImATeapot, AuthenticationTimeout, Code420, Code421, UnprocessableEntity, Locked, FailedDependency, UnorderedCollection, UpgradeRequired, Code427, PreconditionRequired, TooManyRequests, Code430, RequestHeaderFieldsTooLarge, Code432, Code433, Code434, Code435, Code436, Code437, Code438, Code439, Code440, Code441, Code442, Code443, Code444, Code445, Code446, Code447, Code448, Code449, Code450, UnavailableForLegalReasons, Code452, Code453, Code454, Code455, Code456, Code457, Code458, Code459, Code460, Code461, Code462, Code463, Code464, Code465, Code466, Code467, Code468, Code469, Code470, Code471, Code472, Code473, Code474, Code475, Code476, Code477, Code478, Code479, Code480, Code481, Code482, Code483, Code484, Code485, Code486, Code487, Code488, Code489, Code490, Code491, Code492, Code493, Code494, Code495, Code496, Code497, Code498, Code499, InternalServerError, NotImplemented, BadGateway, ServiceUnavailable, GatewayTimeout, HttpVersionNotSupported, VariantAlsoNegotiates, InsufficientStorage, LoopDetected, Code509, NotExtended, NetworkAuthenticationRequired, Code512, Code513, Code514, Code515, Code516, Code517, Code518, Code519, Code520, Code521, Code522, Code523, Code524, Code525, Code526, Code527, Code528, Code529, Code530, Code531, Code532, Code533, Code534, Code535, Code536, Code537, Code538, Code539, Code540, Code541, Code542, Code543, Code544, Code545, Code546, Code547, Code548, Code549, Code550, Code551, Code552, Code553, Code554, Code555, Code556, Code557, Code558, Code559, Code560, Code561, Code562, Code563, Code564, Code565, Code566, Code567, Code568, Code569, Code570, Code571, Code572, Code573, Code574, Code575, Code576, Code577, Code578, Code579, Code580, Code581, Code582, Code583, Code584, Code585, Code586, Code587, Code588, Code589, Code590, Code591, Code592, Code593, Code594, Code595, Code596, Code597, Code598, Code599, }
An HTTP status code (Status-Code
in RFC 2616).
This enum is absolutely exhaustive, covering all 500 possible values (100–599).
For HTTP/2.0, statuses belonging to the 1xx Informational class are invalid.
As this is a C‐style enum with each variant having a corresponding value, you may use the likes
of Continue as u16
to retreive the value 100u16
. Normally, though, you should not need to do
any such thing; just use the status code as a StatusCode
.
If you encounter a status code that you do not know how to deal with, you should treat it as the
x00
status code—e.g. for code 123, treat it as 100 (Continue). This can be achieved with
self.class().default_code()
:
assert_eq!(Code123.class().default_code(), Continue);
Variants
Methods
impl StatusCode
fn canonical_reason(&self) -> Option<&'static str>
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 derive any meaning from it at all costs.
Bear in mind also that in HTTP/2.0 the reason phrase is abolished from transmission, and so this canonical reason phrase really is the only reason phrase you’ll find.
fn class(&self) -> StatusClass
Determine the class of a status code, based on its first digit.
Trait Implementations
impl Copy for StatusCode
impl String for StatusCode
Formats the status code, including the canonical reason.
assert_eq!(&format!("{}", ImATeapot)[], "418 I'm a teapot"); assert_eq!(&format!("{}", Code123)[], "123 <unknown status code>");
If you wish to just include the number, cast to a u16 instead.