doh_dns/
status.rs

1//! Status codes returned from the DNS over HTTPS server.
2use std::fmt;
3/// These codes were obtained from
4/// <https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-6>.
5#[derive(Debug, FromPrimitive)]
6pub enum RCode {
7    /// No Error.
8    NoError,
9    /// Format Error.
10    FormErr,
11    /// Server Failure.
12    ServFail,
13    /// Non-Existent Domain.
14    NXDomain,
15    /// Not Implemented. Cloudflare returns this for all `ANY` DNS requests.
16    NotImp,
17    /// Query Refused.
18    Refused,
19    /// Name Exists when it should not.
20    YXDomain,
21    /// RR Set Exists when it should not.
22    YXRRSet,
23    /// RR Set that should exist does not.
24    NXRRSet,
25    /// Server Not Authoritative for zone.
26    NotAuth,
27    /// Name not contained in zone.
28    NotZone,
29    /// DSO-TYPE Not Implemented.
30    DSOTYPENI,
31    /// Unassigned.
32    Unassigned12,
33    /// Unassigned.
34    Unassigned13,
35    /// Unassigned.
36    Unassigned14,
37    /// Unassigned.
38    Unassigned15,
39    /// Bad OPT Version.
40    BADVERS,
41    /// Key not recognized.
42    BADKEY,
43    /// Signature out of time window.
44    BADTIME,
45    /// Bad TKEY Mode.
46    BADMODE,
47    /// Duplicate key name.
48    BADNAME,
49    /// Algorithm not supported.
50    BADALG,
51    /// Bad Truncation.
52    BADTRUNC,
53    /// Bad/missing Server Cookie.
54    BADCOOKIE,
55    /// Unknown.
56    Unknown,
57}
58
59impl fmt::Display for RCode {
60    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
61        match *self {
62            RCode::NoError => write!(f, "No Error"),
63            RCode::FormErr => write!(f, "Format Error"),
64            RCode::ServFail => write!(f, "Server Failure"),
65            RCode::NXDomain => write!(f, "Non-Existent Domain"),
66            RCode::NotImp => write!(f, "Not Implemented"),
67            RCode::Refused => write!(f, "Query Refused"),
68            RCode::YXDomain => write!(f, "Name Exists when it should not"),
69            RCode::YXRRSet => write!(f, "RR Set Exists when it should not"),
70            RCode::NXRRSet => write!(f, "RR Set that should exist does not"),
71            RCode::NotAuth => write!(f, "Server Not Authoritative for zone"),
72            RCode::NotZone => write!(f, "Name not contained in zone"),
73            RCode::DSOTYPENI => write!(f, "DSO-TYPE Not Implemented"),
74            RCode::Unassigned12
75            | RCode::Unassigned13
76            | RCode::Unassigned14
77            | RCode::Unassigned15 => write!(f, "Unassigned"),
78            RCode::BADVERS => write!(f, "Bad OPT Version"),
79            RCode::BADKEY => write!(f, "Key not recognized"),
80            RCode::BADTIME => write!(f, "Signature out of time window"),
81            RCode::BADMODE => write!(f, "Bad TKEY Mode"),
82            RCode::BADNAME => write!(f, "Duplicate key name"),
83            RCode::BADALG => write!(f, "Algorithm not supported"),
84            RCode::BADTRUNC => write!(f, "Bad Truncation"),
85            RCode::BADCOOKIE => write!(f, "Bad/missing Server Cookie"),
86            RCode::Unknown => write!(f, "Unknown"),
87        }
88    }
89}