pub struct DnsResponsePacket {
pub name_tag: u16be,
pub rtype: DnsType,
pub rclass: DnsClass,
pub ttl: u32be,
pub data_len: u16be,
pub data: Vec<u8>,
pub payload: Bytes,
}Expand description
DNS response packet structure.
Fields§
§name_tag: u16be§rtype: DnsType§rclass: DnsClass§ttl: u32be§data_len: u16be§data: Vec<u8>§payload: BytesImplementations§
Source§impl DnsResponsePacket
impl DnsResponsePacket
Sourcepub fn from_buf_mut(buf: &mut &[u8]) -> Option<Self>
pub fn from_buf_mut(buf: &mut &[u8]) -> Option<Self>
Creates a new DnsResponsePacket from a mutable buffer.
Sourcepub fn get_ipv4(&self) -> Option<Ipv4Addr>
pub fn get_ipv4(&self) -> Option<Ipv4Addr>
Returns the IPv4 address if the record type is A and data length is 4 bytes.
Sourcepub fn get_ipv6(&self) -> Option<Ipv6Addr>
pub fn get_ipv6(&self) -> Option<Ipv6Addr>
Returns the IPv6 address if the record type is AAAA and data length is 16 bytes.
Sourcepub fn get_name(&self) -> Option<DnsName>
pub fn get_name(&self) -> Option<DnsName>
Returns the DNS name if the record type is CNAME, NS, or PTR.
Sourcepub fn get_txt_strings(&self) -> Option<Vec<String>>
pub fn get_txt_strings(&self) -> Option<Vec<String>>
Returns the TXT strings if the record type is TXT.
Trait Implementations§
Source§impl Clone for DnsResponsePacket
impl Clone for DnsResponsePacket
Source§fn clone(&self) -> DnsResponsePacket
fn clone(&self) -> DnsResponsePacket
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DnsResponsePacket
impl Debug for DnsResponsePacket
Source§impl Packet for DnsResponsePacket
impl Packet for DnsResponsePacket
type Header = ()
Source§fn from_bytes(bytes: Bytes) -> Option<Self>
fn from_bytes(bytes: Bytes) -> Option<Self>
Parse from raw bytes. (with ownership)
Source§fn header_len(&self) -> usize
fn header_len(&self) -> usize
Get the length of the header.
Source§fn payload_len(&self) -> usize
fn payload_len(&self) -> usize
Get the length of the payload.
fn into_parts(self) -> (Self::Header, Bytes)
Source§fn to_bytes_mut(&self) -> BytesMut
fn to_bytes_mut(&self) -> BytesMut
Convert the packet to a mutable byte buffer.
Source§fn header_mut(&self) -> BytesMut
fn header_mut(&self) -> BytesMut
Get a mutable byte buffer for the header.
Source§fn payload_mut(&self) -> BytesMut
fn payload_mut(&self) -> BytesMut
Get a mutable byte buffer for the payload.
Source§impl PartialEq for DnsResponsePacket
impl PartialEq for DnsResponsePacket
impl Eq for DnsResponsePacket
impl StructuralPartialEq for DnsResponsePacket
Auto Trait Implementations§
impl !Freeze for DnsResponsePacket
impl RefUnwindSafe for DnsResponsePacket
impl Send for DnsResponsePacket
impl Sync for DnsResponsePacket
impl Unpin for DnsResponsePacket
impl UnwindSafe for DnsResponsePacket
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more