summaryrefslogtreecommitdiff
path: root/packet/src/result.rs
diff options
context:
space:
mode:
Diffstat (limited to 'packet/src/result.rs')
-rw-r--r--packet/src/result.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/packet/src/result.rs b/packet/src/result.rs
new file mode 100644
index 0000000..66108b8
--- /dev/null
+++ b/packet/src/result.rs
@@ -0,0 +1,22 @@
+#[derive(Copy, Clone, Debug, PartialEq, Eq)]
+pub enum ResultCode {
+ NOERROR = 0,
+ FORMERR = 1,
+ SERVFAIL = 2,
+ NXDOMAIN = 3,
+ NOTIMP = 4,
+ REFUSED = 5,
+}
+
+impl ResultCode {
+ pub fn from_num(num: u8) -> ResultCode {
+ match num {
+ 1 => ResultCode::FORMERR,
+ 2 => ResultCode::SERVFAIL,
+ 3 => ResultCode::NXDOMAIN,
+ 4 => ResultCode::NOTIMP,
+ 5 => ResultCode::REFUSED,
+ 0 | _ => ResultCode::NOERROR,
+ }
+ }
+} \ No newline at end of file