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 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
This call will allocate a Vec<u8>
of 900 bytes, which is enough for a jumbo UDP packet
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Packet<'a>
impl<'a> RefUnwindSafe for Packet<'a>
impl<'a> Send for Packet<'a>
impl<'a> Sync for Packet<'a>
impl<'a> Unpin for Packet<'a>
impl<'a> UnwindSafe for Packet<'a>
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)