pub struct DnsPacket<T: AsRef<[u8]>> { /* private fields */ }
Expand description
A read/write wrapper around a DNS packet buffer.
Implementations§
Source§impl<T: AsRef<[u8]>> Packet<T>
impl<T: AsRef<[u8]>> Packet<T>
Sourcepub const fn new_unchecked(buffer: T) -> Packet<T>
pub const fn new_unchecked(buffer: T) -> Packet<T>
Imbue a raw octet buffer with DNS packet structure.
Sourcepub fn new_checked(buffer: T) -> Result<Packet<T>>
pub fn new_checked(buffer: T) -> Result<Packet<T>>
Shorthand for a combination of new_unchecked and check_len.
Sourcepub fn check_len(&self) -> Result<()>
pub fn check_len(&self) -> Result<()>
Ensure that no accessor method will panic if called.
Returns Err(Error)
if the buffer is smaller than
the header length.
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consume the packet, returning the underlying buffer.
pub fn payload(&self) -> &[u8]
pub fn transaction_id(&self) -> u16
pub fn flags(&self) -> Flags
pub fn opcode(&self) -> Opcode
pub fn rcode(&self) -> Rcode
pub fn question_count(&self) -> u16
pub fn answer_record_count(&self) -> u16
pub fn additional_record_count(&self) -> u16
Sourcepub fn parse_name<'a>(
&'a self,
bytes: &'a [u8],
) -> impl Iterator<Item = Result<&'a [u8]>>
pub fn parse_name<'a>( &'a self, bytes: &'a [u8], ) -> impl Iterator<Item = Result<&'a [u8]>>
Parse part of a name from bytes
, following pointers if any.