nova_core/types/
status.rs

1use std::fmt::{Display, Formatter};
2
3/// Nova `HTTPStatus`
4#[derive(Clone, Copy, Debug, Default)]
5pub enum HttpStatus {
6    /// Http Status 100: Continue
7    Continue,
8    /// Http Status 101: Switching Protocols
9    SwitchingProtocols,
10    /// Http Status 102: Processing
11    Processing,
12    /// Http Status 103: Early Hints
13    EarlyHints,
14    /// Http Status 200: OK
15    #[default]
16    OK,
17    /// Http Status 201: Created
18    Created,
19    /// Http Status 202: Accepted
20    Accepted,
21    /// Http Status 203: Non-Authoritative Information
22    NonAuthoritativeInformation,
23    /// Http Status 204: No Content
24    NoContent,
25    /// Http Status 205: Reset Content
26    ResetContent,
27    /// Http Status 206: Partial Content
28    PartialContent,
29    /// Http Status 207: Multi-Status
30    MultiStatus,
31    /// Http Status 300: Multiple Choices
32    MultipleChoices,
33    /// Http Status 301: Moved Permanently
34    MovedPermanently,
35    /// Http Status 302: Found
36    Found,
37    /// Http Status 303: See Other
38    SeeOther,
39    /// Http Status 304: Not Modified
40    NotModified,
41    /// Http Status 305: Use Proxy
42    UseProxy,
43    /// Http Status 306: (Unused)
44    Unused,
45    /// Http Status 307: Temporary Redirect
46    TemporaryRedirect,
47    /// Http Status 308: Permanent Redirect
48    PermanentRedirect,
49    /// Http Status 400: Bad Request
50    BadRequest,
51    /// Http Status 401: Unauthorized
52    Unauthorized,
53    /// Http Status 402: Payment Required
54    PaymentRequired,
55    /// Http Status 403: Forbidden
56    Forbidden,
57    /// Http Status 404: Not Found
58    NotFound,
59    /// Http Status 405: Method Not Allowed
60    MethodNotAllowed,
61    /// Http Status 406: Not Acceptable
62    NotAcceptable,
63    /// Http Status 407: Proxy Authentication Required
64    ProxyAuthenticationRequired,
65    /// Http Status 408: Request Timeout
66    RequestTimeout,
67    /// Http Status 409: Conflict
68    Conflict,
69    /// Http Status 410: Gone
70    Gone,
71    /// Http Status 411: Length Required
72    LengthRequired,
73    /// Http Status 412: Precondition Failed
74    PreconditionFailed,
75    /// Http Status 413: Request Entity Too Large
76    RequestEntityTooLarge,
77    /// Http Status 414: Request-URI Too Long
78    RequestURITooLong,
79    /// Http Status 415: Unsupported Media Type
80    UnsupportedMediaType,
81    /// Http Status 416: Requested Range Not Satisfiable
82    RequestedRangeNotSatisfiable,
83    /// Http Status 417: Expectation Failed
84    ExpectationFailed,
85    /// Http Status 418: I'm a teapot
86    ImATeapot,
87    /// Http Status 420: Enhance Your Calm
88    EnhanceYourCalm,
89    /// Http Status 421: Misdirected Request
90    MisdirectedRequest,
91    /// Http Status 422: Unprocessable Entity
92    UnprocessableEntity,
93    /// Http Status 423: Locked
94    Locked,
95    /// Http Status 424: Failed Dependency
96    FailedDependency,
97    /// Http Status 425: Too Early
98    TooEarly,
99    /// Http Status 426: Upgrade Required
100    UpgradeRequired,
101    /// Http Status 428: Precondition Required
102    PreconditionRequired,
103    /// Http Status 429: Too Many Requests
104    TooManyRequests,
105    /// Http Status 431: Request Header Fields Too Large
106    RequestHeaderFieldsTooLarge,
107    /// Http Status 444: No Response
108    NoResponse,
109    /// Http Status 450: Blocked by Windows Parental Control
110    BlockedByWindowsParentalControls,
111    /// Http Status 451: Unavailable For Legal Reasons
112    UnavailableForLegalReasons,
113    /// Http Status 500: Internal Server Error
114    InternalServerError,
115    /// Http Status 501: Not Implemented
116    NotImplemented,
117    /// Http Status 502: Bad Gateway
118    BadGateway,
119    /// Http Status 503: Service Unavailable
120    ServiceUnavailable,
121    /// Http Status 504: Gateway Timeout
122    GatewayTimeout,
123    /// Http Status 505: HTTP Version Not Supported
124    HTTPVersionNotSupported,
125    /// Http Status 506: Variant Also Negotiates
126    VariantAlsoNegotiates,
127    /// Http Status 507: Insufficient Storage
128    InsufficientStorage,
129    /// Http Status 508: Loop Detected
130    LoopDetected,
131    /// Http Status 510: Not Extended
132    NotExtended,
133    /// Http Status 511: Network Authentication Required
134    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}