1use std::fmt::{Display, Formatter};
2
3#[derive(Clone, Copy, Debug, Default)]
5pub enum HttpStatus {
6 Continue,
8 SwitchingProtocols,
10 Processing,
12 EarlyHints,
14 #[default]
16 OK,
17 Created,
19 Accepted,
21 NonAuthoritativeInformation,
23 NoContent,
25 ResetContent,
27 PartialContent,
29 MultiStatus,
31 MultipleChoices,
33 MovedPermanently,
35 Found,
37 SeeOther,
39 NotModified,
41 UseProxy,
43 Unused,
45 TemporaryRedirect,
47 PermanentRedirect,
49 BadRequest,
51 Unauthorized,
53 PaymentRequired,
55 Forbidden,
57 NotFound,
59 MethodNotAllowed,
61 NotAcceptable,
63 ProxyAuthenticationRequired,
65 RequestTimeout,
67 Conflict,
69 Gone,
71 LengthRequired,
73 PreconditionFailed,
75 RequestEntityTooLarge,
77 RequestURITooLong,
79 UnsupportedMediaType,
81 RequestedRangeNotSatisfiable,
83 ExpectationFailed,
85 ImATeapot,
87 EnhanceYourCalm,
89 MisdirectedRequest,
91 UnprocessableEntity,
93 Locked,
95 FailedDependency,
97 TooEarly,
99 UpgradeRequired,
101 PreconditionRequired,
103 TooManyRequests,
105 RequestHeaderFieldsTooLarge,
107 NoResponse,
109 BlockedByWindowsParentalControls,
111 UnavailableForLegalReasons,
113 InternalServerError,
115 NotImplemented,
117 BadGateway,
119 ServiceUnavailable,
121 GatewayTimeout,
123 HTTPVersionNotSupported,
125 VariantAlsoNegotiates,
127 InsufficientStorage,
129 LoopDetected,
131 NotExtended,
133 NetworkAuthenticationRequired,
135}
136
137impl Display for HttpStatus {
138 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
139 match self {
140 Self::Continue => write!(f, "100 Continue"),
141 Self::SwitchingProtocols => write!(f, "101 Switching Protocols"),
142 Self::Processing => write!(f, "102 Processing"),
143 Self::EarlyHints => write!(f, "103 Early Hints"),
144 Self::OK => write!(f, "200 Ok"),
145 Self::Created => write!(f, "201 Created"),
146 Self::Accepted => write!(f, "202 Accepted"),
147 Self::NonAuthoritativeInformation => {
148 write!(f, "203 Non-Authoritative Information")
149 }
150 Self::NoContent => write!(f, "204 No Content"),
151 Self::ResetContent => write!(f, "205 Reset Content"),
152 Self::PartialContent => write!(f, "206 Partial Content"),
153 Self::MultiStatus => write!(f, "207 Multi-Status"),
154 Self::MultipleChoices => write!(f, "300 Multiple Choices"),
155 Self::MovedPermanently => write!(f, "301 Moved Permanently"),
156 Self::Found => write!(f, "302 Found"),
157 Self::SeeOther => write!(f, "303 See Other"),
158 Self::NotModified => write!(f, "304 Not Modified"),
159 Self::UseProxy => write!(f, "305 Use Proxy"),
160 Self::Unused => write!(f, "306 Unused"),
161 Self::TemporaryRedirect => write!(f, "307 Temporary Redirect"),
162 Self::PermanentRedirect => write!(f, "308 Permanent Redirect"),
163 Self::BadRequest => write!(f, "400 Bad Request"),
164 Self::Unauthorized => write!(f, "401 Unauthorized"),
165 Self::PaymentRequired => write!(f, "402 Payment Required"),
166 Self::Forbidden => write!(f, "403 Forbidden"),
167 Self::NotFound => write!(f, "404 Not Found"),
168 Self::MethodNotAllowed => write!(f, "405 Method Not Allowed"),
169 Self::NotAcceptable => write!(f, "406 Not Acceptable"),
170 Self::ProxyAuthenticationRequired => {
171 write!(f, "407 Proxy Authentication Required")
172 }
173 Self::RequestTimeout => write!(f, "408 Request Timeout"),
174 Self::Conflict => write!(f, "409 Conflict"),
175 Self::Gone => write!(f, "410 Gone"),
176 Self::LengthRequired => write!(f, "411 Length Required"),
177 Self::PreconditionFailed => write!(f, "412 Precondition Failed"),
178 Self::RequestEntityTooLarge => write!(f, "413 Request Entity Too Large"),
179 Self::RequestURITooLong => write!(f, "414 Request-URI Too Long"),
180 Self::UnsupportedMediaType => write!(f, "415 Unsupported Media Type"),
181 Self::RequestedRangeNotSatisfiable => {
182 write!(f, "416 Requested Range Not Satisfiable")
183 }
184 Self::ExpectationFailed => write!(f, "417 Expectation Failed"),
185 Self::ImATeapot => write!(f, "418 I'm a teapot"),
186 Self::EnhanceYourCalm => write!(f, "420 Enhance Your Calm"),
187 Self::MisdirectedRequest => write!(f, "421 Misdirected Request"),
188 Self::UnprocessableEntity => write!(f, "422 Unprocessable Entity"),
189 Self::Locked => write!(f, "423 Locked"),
190 Self::FailedDependency => write!(f, "424 Failed Dependency"),
191 Self::TooEarly => write!(f, "425 Too Early"),
192 Self::UpgradeRequired => write!(f, "426 Upgrade Required"),
193 Self::PreconditionRequired => write!(f, "428 Precondition Required"),
194 Self::TooManyRequests => write!(f, "429 Too Many Requests"),
195 Self::RequestHeaderFieldsTooLarge => {
196 write!(f, "431 Request Header Fields Too Large")
197 }
198 Self::NoResponse => write!(f, "444 No Response"),
199 Self::BlockedByWindowsParentalControls => {
200 write!(f, "450 Blocked By Windows Parental Controls")
201 }
202 Self::UnavailableForLegalReasons => {
203 write!(f, "451 Unavailable For Legal Reasons")
204 }
205 Self::InternalServerError => write!(f, "500 Internal Server Error"),
206 Self::NotImplemented => write!(f, "501 Not Implemented"),
207 Self::BadGateway => write!(f, "502 Bad Gateway"),
208 Self::ServiceUnavailable => write!(f, "503 Service Unavailable"),
209 Self::GatewayTimeout => write!(f, "504 Gateway Timeout"),
210 Self::HTTPVersionNotSupported => write!(f, "505 HTTP Version Not Supported"),
211 Self::VariantAlsoNegotiates => write!(f, "506 Variant Also Negotiates"),
212 Self::InsufficientStorage => write!(f, "507 Insufficient Storage"),
213 Self::LoopDetected => write!(f, "508 Loop Detected"),
214 Self::NotExtended => write!(f, "510 Not Extended"),
215 Self::NetworkAuthenticationRequired => {
216 write!(f, "511 Network Authentication Required")
217 }
218 }
219 }
220}