1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/// Status codes as specified in [the spec](https://gemini.circumlunar.space/docs/specification.html).
#[derive(Copy, Clone, num_derive::FromPrimitive, PartialEq, Debug)]
pub enum StatusCode {
/// The requested resource accepts a line of textual user input.
/// The <META> line is a prompt which should be displayed to the
/// user. The same resource should then be requested again with the
/// user's input included as a query component. Queries are
/// included in requests as per the usual generic URL definition in
/// RFC3986, i.e. separated from the path by a ?. Reserved characters
/// used in the user's input must be "percent-encoded" as per RFC3986,
/// and space characters should also be percent-encoded.
Input = 10,
/// As per status code 10, but for use with sensitive input such as
/// passwords. Clients should present the prompt as per status code
/// 10, but the user's input should not be echoed to the screen to
/// prevent it being read by "shoulder surfers".
SensitiveInput = 11,
/// The request was handled successfully and a response body will follow the response header. The <META> line is a MIME media type which applies to the response body.
Success = 20,
/// The server is redirecting the client to a new location for the
/// requested resource. There is no response body. <META> is a new
/// URL for the requested resource. The URL may be absolute or
/// relative. The redirect should be considered temporary, i.e.
/// clients should continue to request the resource at the original
/// address and should not performance convenience actions like
/// automatically updating bookmarks. There is no response body.
TemporaryRedirect = 30,
/// The requested resource should be consistently requested from the
/// new URL provided in future. Tools like search engine indexers or
/// content aggregators should update their configurations to avoid
/// requesting the old URL, and end-user clients may automatically
/// update bookmarks, etc. Note that clients which only pay attention
/// to the initial digit of status codes will treat this as a temporary
/// redirect. They will still end up at the right place, they just
/// won't be able to make use of the knowledge that this redirect is
/// permanent, so they'll pay a small performance penalty by having
///to follow the redirect each time.
PermanentRedirect = 31,
/// The request has failed. There is no response body. The nature of
/// the failure is temporary, i.e. an identical request MAY succeed
/// in the future. The contents of <META> may provide additional
/// information on the failure, and should be displayed to human users.
TemporaryFailure = 40,
/// The server is unavailable due to overload or maintenance. (cf HTTP
/// 503)
ServerUnavailable = 41,
/// A CGI process, or similar system for generating dynamic content,
/// died unexpectedly or timed out.
CGIError = 42,
/// A proxy request failed because the server was unable to
/// successfully complete a transaction with the remote host. (cf HTTP
/// 502, 504)
ProxyError = 43,
/// Rate limiting is in effect. <META> is an integer number of seconds
/// which the client must wait before another request is made to this
/// server. (cf HTTP 429)
SlowDown = 44,
/// The request has failed. There is no response body. The nature of
/// the failure is permanent, i.e. identical future requests will
/// reliably fail for the same reason. The contents of <META> may
/// provide additional information on the failure, and should be
/// displayed to human users. Automatic clients such as aggregators
/// or indexing crawlers should not repeat this request.
PermanentFailure = 50,
/// The requested resource could not be found but may be available in
/// the future. (cf HTTP 404) (struggling to remember this important
/// status code? Easy: you can't find things hidden at Area 51!)
NotFound = 51,
/// The resource requested is no longer available and will not be
/// available again. Search engines and similar tools should remove this
/// resource from their indices. Content aggregators should stop
/// requesting the resource and convey to their human users that the
/// subscribed resource is gone. (cf HTTP 410)
Gone = 52,
/// The request was for a resource at a domain not served by the server
/// and the server does not accept proxy requests.
ProxyRequestRefused = 53,
/// The server was unable to parse the client's request, presumably due
/// to a malformed request. (cf HTTP 400)
BadRequest = 59,
/// The requested resource requires a client certificate to access. If
/// the request was made without a certificate, it should be repeated
/// with one. If the request was made with a certificate, the server
/// did not accept it and the request should be repeated with a
/// different certificate. The contents of <META> (and/or the specific
/// 6x code) may provide additional information on certificate
/// requirements or the reason a certificate was rejected.
ClientCertificateRequired = 60,
/// The supplied client certificate is not authorised for accessing the
/// particular requested resource. The problem is not with the
/// certificate itself, which may be authorised for other resources.
CertificateNotAuthorized = 61,
/// The supplied client certificate was not accepted because it is not
/// valid. This indicates a problem with the certificate in and of itself,
/// with no consideration of the particular requested resource. The most
/// likely cause is that the certificate's validity start date is in the
/// future or its expiry date has passed, but this code may also
/// indicate an invalid signature, or a violation of a X509 standard
/// requirements. The <META> should provide more information about the
/// exact error.
CertificateNotValid = 62,
}
impl StatusCode {
// Converts this StatusCode to its numerical representation, consuming it.
pub fn num(self) -> u8 {
self as u8
}
}
impl Default for StatusCode {
fn default() -> Self {
StatusCode::Success
}
}