http_async/
status.rs

1use
2{
3  std::
4  {
5    fmt::
6    {
7      self,
8      Display,
9    },
10  },
11};
12
13/// Status Code of Response.
14#[allow(dead_code)]
15pub enum      Status
16{
17  /// 100 – Continue, see [RFC7231, Section 6.2.1].
18  Continue,
19  /// 101 – Switching Protocols, see [RFC7231, Section 6.2.2].
20  SwitchingProtocols,
21  /// 102 – Processing, see [RFC2518].
22  Processing,
23  /// 103 – Early Hints, see [RFC8297].
24  EarlyHints,
25  /// 200 – OK, see [RFC7231, Section 6.3.1].
26  Ok,
27  /// 201 – Created, see [RFC7231, Section 6.3.2].
28  Created,
29  /// 202 – Accepted, see [RFC7231, Section 6.3.3].
30  Accepted,
31  /// 203 – Non-Authoritative Information, see [RFC7231, Section 6.3.4].
32  NonAuthoritativeInformation,
33  /// 204 – No Content, see [RFC7231, Section 6.3.5].
34  NoContent,
35  /// 205 – Reset Content, see [RFC7231, Section 6.3.6].
36  ResetContent,
37  /// 206 – Partial Content, see [RFC7233, Section 4.1].
38  PartialContent,
39  /// 207 – Multi-Status, see [RFC4918].
40  MultiStatus,
41  /// 208 – Already Reported, see [RFC5842].
42  AlreadyReported,
43  /// 226 – IM Used, see [RFC3229].
44  IMUsed,
45  /// 300 – Multiple Choices, see [RFC7231, Section 6.4.1].
46  MultipleChoices,
47  /// 301 – Moved Permanently, see [RFC7231, Section 6.4.2].
48  MovedPermanently,
49  /// 302 – Found, see [RFC7231, Section 6.4.3].
50  Found,
51  /// 303 – See Other, see [RFC7231, Section 6.4.4].
52  SeeOther,
53  /// 304 – Not Modified, see [RFC7232, Section 4.1].
54  NotModified,
55  /// 305 – Use Proxy, see [RFC7231, Section 6.4.5].
56  UseProxy,
57  /// 307 – Temporary Redirect, see [RFC7231, Section 6.4.7].
58  TemporaryRedirect,
59  /// 308 – Permanent Redirect, see [RFC7538].
60  PermanentRedirect,
61  /// 400 – Bad Request, see [RFC7231, Section 6.5.1].
62  BadRequest,
63  /// 401 – Unauthorized, see [RFC7235, Section 3.1].
64  Unauthorized,
65  /// 402 – Payment Required, see [RFC7231, Section 6.5.2].
66  PaymentRequired,
67  /// 403 – Forbidden, see [RFC7231, Section 6.5.3].
68  Forbidden,
69  /// 404 – Not Found, see [RFC7231, Section 6.5.4].
70  NotFound,
71  /// 405 – Method Not Allowed, see [RFC7231, Section 6.5.5].
72  MethodNotAllowed,
73  /// 406 – Not Acceptable, see [RFC7231, Section 6.5.6].
74  NotAcceptable,
75  /// 407 – Proxy Authentication Required, see [RFC7235, Section 3.2].
76  ProxyAuthenticationRequired,
77  /// 408 – Request Timeout, see [RFC7231, Section 6.5.7].
78  RequestTimeout,
79  /// 409 – Conflict, see [RFC7231, Section 6.5.8].
80  Conflict,
81  /// 410 – Gone, see [RFC7231, Section 6.5.9].
82  Gone,
83  /// 411 – Length Required, see [RFC7231, Section 6.5.10].
84  LengthRequired,
85  /// 412 – Precondition Failed, see [RFC7232, Section 4.2][RFC8144, Section 3.2].
86  PreconditionFailed,
87  /// 413 – Payload Too Large, see [RFC7231, Section 6.5.11].
88  PayloadTooLarge,
89  /// 414 – URI Too Long, see [RFC7231, Section 6.5.12].
90  URITooLong,
91  /// 415 – Unsupported Media Type, see [RFC7231, Section 6.5.13][RFC7694, Section 3].
92  UnsupportedMediaType,
93  /// 416 – Range Not Satisfiable, see [RFC7233, Section 4.4].
94  RangeNotSatisfiable,
95  /// 417 – Expectation Failed, see [RFC7231, Section 6.5.14].
96  ExpectationFailed,
97  /// 421 – Misdirected Request, see [RFC7540, Section 9.1.2].
98  MisdirectedRequest,
99  /// 422 – Unprocessable Entity, see [RFC4918].
100  UnprocessableEntity,
101  /// 423 – Locked, see [RFC4918].
102  Locked,
103  /// 424 – Failed Dependency, see [RFC4918].
104  FailedDependency,
105  /// 425 – Too Early, see [RFC8470].
106  TooEarly,
107  /// 426 – Upgrade Required, see [RFC7231, Section 6.5.15].
108  UpgradeRequired,
109  /// 428 – Precondition Required, see [RFC6585].
110  PreconditionRequired,
111  /// 429 – Too Many Requests, see [RFC6585].
112  TooManyRequests,
113  /// 431 – Request Header Fields Too Large, see [RFC6585].
114  RequestHeaderFieldsTooLarge,
115  /// 451 – Unavailable For Legal Reasons, see [RFC7725].
116  UnavailableForLegalReasons,
117  /// 500 – Internal Server Error, see [RFC7231, Section 6.6.1].
118  InternalServerError,
119  /// 501 – Not Implemented, see [RFC7231, Section 6.6.2].
120  NotImplemented,
121  /// 502 – Bad Gateway, see [RFC7231, Section 6.6.3].
122  BadGateway,
123  /// 503 – Service Unavailable, see [RFC7231, Section 6.6.4].
124  ServiceUnavailable,
125  /// 504 – Gateway Timeout, see [RFC7231, Section 6.6.5].
126  GatewayTimeout,
127  /// 505 – HTTP Version Not Supported, see [RFC7231, Section 6.6.6].
128  HTTPVersionNotSupported,
129  /// 506 – Variant Also Negotiates, see [RFC2295].
130  VariantAlsoNegotiates,
131  /// 507 – Insufficient Storage, see [RFC4918].
132  InsufficientStorage,
133  /// 508 – Loop Detected, see [RFC5842].
134  LoopDetected,
135  /// 510 – Not Extended, see [RFC2774].
136  NotExtended,
137  /// 511 – Network Authentication Required, see [RFC6585].
138  NetworkAuthenticationRequired,
139}
140
141impl          Display                   for Status
142{
143  fn fmt
144  (
145    &self,
146    formatter:                          &mut fmt::Formatter<'_>
147  )
148  ->  fmt::Result
149  {
150    formatter
151      .write_str
152      (
153        &format!
154        (
155          "HTTP/{}",
156          match self
157          {
158            Status::Continue                      =>  "100 Continue",
159            Status::SwitchingProtocols            =>  "101 Switching Protocols",
160            Status::Processing                    =>  "102 Processing",
161            Status::EarlyHints                    =>  "103 Early Hints",
162            Status::Ok                            =>  "200 OK",
163            Status::Created                       =>  "201 Created",
164            Status::Accepted                      =>  "202 Accepted",
165            Status::NonAuthoritativeInformation   =>  "203 Non-Authoritative Information",
166            Status::NoContent                     =>  "204 No Content",
167            Status::ResetContent                  =>  "205 Reset Content",
168            Status::PartialContent                =>  "206 Partial Content",
169            Status::MultiStatus                   =>  "207 Multi-Status",
170            Status::AlreadyReported               =>  "208 Already Reported",
171            Status::IMUsed                        =>  "226 IM Used",
172            Status::MultipleChoices               =>  "300 Multiple Choices",
173            Status::MovedPermanently              =>  "301 Moved Permanently",
174            Status::Found                         =>  "302 Found",
175            Status::SeeOther                      =>  "303 See Other",
176            Status::NotModified                   =>  "304 Not Modified",
177            Status::UseProxy                      =>  "305 Use Proxy",
178            Status::TemporaryRedirect             =>  "307 Temporary Redirect",
179            Status::PermanentRedirect             =>  "308 Permanent Redirect",
180            Status::BadRequest                    =>  "400 Bad Request",
181            Status::Unauthorized                  =>  "401 Unauthorized",
182            Status::PaymentRequired               =>  "402 Payment Required",
183            Status::Forbidden                     =>  "403 Forbidden",
184            Status::NotFound                      =>  "404 Not Found",
185            Status::MethodNotAllowed              =>  "405 Method Not Allowed",
186            Status::NotAcceptable                 =>  "406 Not Acceptable",
187            Status::ProxyAuthenticationRequired   =>  "407 Proxy Authentication Required",
188            Status::RequestTimeout                =>  "408 Request Timeout",
189            Status::Conflict                      =>  "409 Conflict",
190            Status::Gone                          =>  "410 Gone",
191            Status::LengthRequired                =>  "411 Length Required",
192            Status::PreconditionFailed            =>  "412 Precondition Failed",
193            Status::PayloadTooLarge               =>  "413 Payload Too Large",
194            Status::URITooLong                    =>  "414 URI Too Long",
195            Status::UnsupportedMediaType          =>  "415 Unsupported Media Type",
196            Status::RangeNotSatisfiable           =>  "416 Range Not Satisfiable",
197            Status::ExpectationFailed             =>  "417 Expectation Failed",
198            Status::MisdirectedRequest            =>  "421 Misdirected Request",
199            Status::UnprocessableEntity           =>  "422 Unprocessable Entity",
200            Status::Locked                        =>  "423 Locked",
201            Status::FailedDependency              =>  "424 Failed Dependency",
202            Status::TooEarly                      =>  "425 Too Early",
203            Status::UpgradeRequired               =>  "426 Upgrade Required",
204            Status::PreconditionRequired          =>  "428 Precondition Required",
205            Status::TooManyRequests               =>  "429 Too Many Requests",
206            Status::RequestHeaderFieldsTooLarge   =>  "431 Request Header Fields Too Large",
207            Status::UnavailableForLegalReasons    =>  "451 Unavailable For Legal Reasons",
208            Status::InternalServerError           =>  "500 Internal Server Error",
209            Status::NotImplemented                =>  "501 Not Implemented",
210            Status::BadGateway                    =>  "502 Bad Gateway",
211            Status::ServiceUnavailable            =>  "503 Service Unavailable",
212            Status::GatewayTimeout                =>  "504 Gateway Timeout",
213            Status::HTTPVersionNotSupported       =>  "505 HTTP Version Not Supported",
214            Status::VariantAlsoNegotiates         =>  "506 Variant Also Negotiates",
215            Status::InsufficientStorage           =>  "507 Insufficient Storage",
216            Status::LoopDetected                  =>  "508 Loop Detected",
217            Status::NotExtended                   =>  "510 Not Extended",
218            Status::NetworkAuthenticationRequired =>  "511 Network Authentication Required",
219          }
220        )
221      )
222  }
223}