From c67c940ba973f7473dca1095913ad8c52ab32a4c Mon Sep 17 00:00:00 2001 From: Tobias Ottenweller Date: Sun, 3 Apr 2022 17:10:59 +0200 Subject: [PATCH] Improve code styling --- src/proto.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/proto.rs b/src/proto.rs index a29828a..838c0c9 100644 --- a/src/proto.rs +++ b/src/proto.rs @@ -38,12 +38,6 @@ pub enum DNSRCode { NOTINZONE = 10, } -#[derive(Debug)] -pub enum DNSParseErr { - DatagramLengthError, - SliceError(std::array::TryFromSliceError) -} - impl From for DNSRCode { fn from(val: u16) -> Self { match val { @@ -115,9 +109,9 @@ impl DNSHeader { const OPCODE_OFFSET: u16 = 1; const RCODE_OFFSET: u16 = 11; - pub fn from_udp_datagram(datagram: &[u8]) -> Result { + pub fn from_udp_datagram(datagram: &[u8]) -> Result { if datagram.len() < 11 { - return Err(DNSParseErr::DatagramLengthError); + return Err(DNSParseError::DatagramLengthError); } let id = u16::from_be_bytes((&datagram[..2]).try_into()?); @@ -157,8 +151,14 @@ impl DNSHeader { } } -impl From for DNSParseErr { +#[derive(Debug)] +pub enum DNSParseError { + DatagramLengthError, + SliceError(std::array::TryFromSliceError) +} + +impl From for DNSParseError { fn from(err: std::array::TryFromSliceError) -> Self { - DNSParseErr::SliceError(err) + DNSParseError::SliceError(err) } }