~kf5jwc/dns-server-rs

db924697592f887f598491228f21796025b5273d — Kyle Jones 6 months ago 9d9b76d
Simplify Into/From trait impl
1 files changed, 6 insertions(+), 12 deletions(-)

M src/dns_packet/query_type.rs
M src/dns_packet/query_type.rs => src/dns_packet/query_type.rs +6 -12
@@ 26,24 26,18 @@ impl Into<u16> for QueryType {

impl Into<u32> for QueryType {
    fn into(self) -> u32 {
        match self {
            Self::UNKNOWN(x) => x as u32,
            Self::A => 1,
        }
        Into::<u16>::into(self) as u32
    }
}

impl From<u16> for QueryType {
    fn from(num: u16) -> Self {
        match num {
            1 => Self::A,
            _ => Self::UNKNOWN(num),
        }
impl From<u32> for QueryType {
    fn from(num: u32) -> Self {
        Into::<QueryType>::into(num as u16)
    }
}

impl From<u32> for QueryType {
    fn from(num: u32) -> Self {
impl From<u16> for QueryType {
    fn from(num: u16) -> Self {
        match num {
            01 => Self::A,
            02 => Self::NS,