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
/// The class of a DNS query. /// /// According to [RFC 1035 Section 3.2.4](https://tools.ietf.org/rfc/rfc1035#section-3.2.4). #[derive(Copy, Clone, Debug, PartialEq)] #[repr(u16)] pub enum QueryClass { /// Internet IN = 1, /// CSNET CS = 2, /// CHAOS CH = 3, /// Hesiod HS = 4, Reserved, } impl QueryClass { pub fn to_be_bytes(&self) -> [u8; 2] { (*self as u16).to_be_bytes() } } impl From<u16> for QueryClass { fn from(n: u16) -> Self { match n { 1 => Self::IN, 2 => Self::CS, 3 => Self::CH, 4 => Self::HS, _ => Self::Reserved, } } }