diff options
Diffstat (limited to 'packet/src/query.rs')
-rw-r--r-- | packet/src/query.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/packet/src/query.rs b/packet/src/query.rs new file mode 100644 index 0000000..ac993bd --- /dev/null +++ b/packet/src/query.rs @@ -0,0 +1,33 @@ +#[derive(PartialEq, Eq, Debug, Clone, Hash, Copy)] +pub enum QueryType { + UNKNOWN(u16), + A, // 1 + NS, // 2 + CNAME, // 5 + MX, // 15 + AAAA, // 28 +} + +impl QueryType { + pub fn to_num(&self) -> u16 { + match *self { + QueryType::UNKNOWN(x) => x, + QueryType::A => 1, + QueryType::NS => 2, + QueryType::CNAME => 5, + QueryType::MX => 15, + QueryType::AAAA => 28, + } + } + + pub fn from_num(num: u16) -> QueryType { + match num { + 1 => QueryType::A, + 2 => QueryType::NS, + 5 => QueryType::CNAME, + 15 => QueryType::MX, + 28 => QueryType::AAAA, + _ => QueryType::UNKNOWN(num), + } + } +}
\ No newline at end of file |