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 Packet::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 rcode_mut(&mut self) -> &mut RCODE
pub fn rcode_mut(&mut self) -> &mut RCODE
Get a mutable reference for this packet RCODE information Warning, if the RCODE value is greater than 15 (4 bits), you MUST provide an OPT resource record through the Packet::opt_mut function
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
Names are only compressed against byte-identical names. Names that are equal under DNS
case-insensitive comparison but differ in casing (Foo.local and foo.local) are written
in full, so the casing of every name is preserved when the packet is parsed again.
This call will allocate a Vec<u8> of 900 bytes, which is enough for a jumbo UDP packet
Sourcepub fn write_to<T: Write>(&self, out: &mut T) -> Result<()>
pub fn write_to<T: Write>(&self, out: &mut T) -> Result<()>
Write the contents of this package in wire format into the provided writer
Sourcepub fn write_compressed_to<T: Write + Seek>(&self, out: &mut T) -> Result<()>
pub fn write_compressed_to<T: Write + Seek>(&self, out: &mut T) -> Result<()>
Write the contents of this package in wire format with enabled compression into the provided writer
Names are only compressed against byte-identical names. Names that are equal under DNS
case-insensitive comparison but differ in casing (Foo.local and foo.local) are written
in full, so the casing of every name is preserved when the packet is parsed again.