// DNS protocol names used by the CLI and human-readable formatters.

///|
pub fn qtype_to_string(qtype : UInt16) -> String {
  if qtype == qtype_a {
    "A"
  } else if qtype == qtype_aaaa {
    "AAAA"
  } else if qtype == qtype_mx {
    "MX"
  } else if qtype == qtype_ns {
    "NS"
  } else if qtype == qtype_cname {
    "CNAME"
  } else if qtype == qtype_soa {
    "SOA"
  } else if qtype == qtype_ptr {
    "PTR"
  } else if qtype == qtype_txt {
    "TXT"
  } else if qtype == qtype_srv {
    "SRV"
  } else if qtype == qtype_opt {
    "OPT"
  } else if qtype == qtype_any {
    "ANY"
  } else {
    "TYPE" + qtype.to_string()
  }
}

///|
pub fn rcode_to_string(rcode : Int) -> String {
  if rcode == rcode_noerror {
    "NOERROR"
  } else if rcode == rcode_formerr {
    "FORMERR"
  } else if rcode == rcode_servfail {
    "SERVFAIL"
  } else if rcode == rcode_nxdomain {
    "NXDOMAIN"
  } else if rcode == rcode_notimp {
    "NOTIMP"
  } else if rcode == rcode_refused {
    "REFUSED"
  } else if rcode == rcode_badvers {
    "BADVERS"
  } else {
    "RCODE" + rcode.to_string()
  }
}