Struct simple_dns::Packet
source · pub struct Packet<'a> {
pub questions: Vec<Question<'a>>,
pub answers: Vec<ResourceRecord<'a>>,
pub name_servers: Vec<ResourceRecord<'a>>,
pub additional_records: Vec<ResourceRecord<'a>>,
/* private fields */
}
Expand description
Represents a DNS message packet
When working with EDNS packets, use Packet::opt and Packet::opt_mut to add or access OPT packet information
Fields§
§questions: Vec<Question<'a>>
Questions section
answers: Vec<ResourceRecord<'a>>
Answers section
name_servers: Vec<ResourceRecord<'a>>
Name servers section
additional_records: Vec<ResourceRecord<'a>>
Aditional records section.
DO NOT use this field to add OPT record, use [opt_mut
] instead
Implementations§
source§impl<'a> Packet<'a>
impl<'a> Packet<'a>
sourcepub fn set_flags(&mut self, flags: PacketFlag)
pub fn set_flags(&mut self, flags: PacketFlag)
Set flags in the packet
sourcepub fn remove_flags(&mut self, flags: PacketFlag)
pub fn remove_flags(&mut self, flags: PacketFlag)
Remove flags present in the packet
sourcepub fn has_flags(&self, flags: PacketFlag) -> bool
pub fn has_flags(&self, flags: PacketFlag) -> bool
Check if the packet has flags set
sourcepub fn opcode_mut(&mut self) -> &mut OPCODE
pub fn opcode_mut(&mut self) -> &mut OPCODE
Get a mutable reference for this packet OPCODE information
sourcepub fn opt_mut(&mut self) -> &mut Option<OPT<'a>>
pub fn opt_mut(&mut self) -> &mut Option<OPT<'a>>
Get a mutable reference for this packet OPT resource record.
sourcepub fn into_reply(self) -> Self
pub fn into_reply(self) -> Self
Changes this packet into a reply packet by replacing its header
sourcepub fn build_bytes_vec(&self) -> Result<Vec<u8>>
pub fn build_bytes_vec(&self) -> Result<Vec<u8>>
Creates a new Vec<u8>
and write the contents of this package in wire format
This call will allocate a Vec<u8>
of 900 bytes, which is enough for a jumbo UDP packet
sourcepub fn build_bytes_vec_compressed(&self) -> Result<Vec<u8>>
pub fn build_bytes_vec_compressed(&self) -> Result<Vec<u8>>
Creates a new Vec<u8>
and write the contents of this package in wire format
with compression enabled
This call will allocate a Vec<u8>
of 900 bytes, which is enough for a jumbo UDP packet