#[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), } } }