Skip to main content

DnsBuilder

Struct DnsBuilder 

Source
pub struct DnsBuilder {
Show 16 fields pub id: u16, pub qr: bool, pub opcode: u8, pub aa: bool, pub tc: bool, pub rd: bool, pub ra: bool, pub z: bool, pub ad: bool, pub cd: bool, pub rcode: u8, pub questions: Vec<DnsQuestion>, pub answers: Vec<DnsResourceRecord>, pub authorities: Vec<DnsResourceRecord>, pub additionals: Vec<DnsResourceRecord>, pub compress: bool,
}
Expand description

Builder for constructing DNS packets.

Fields§

§id: u16

Transaction ID.

§qr: bool

Query/Response flag.

§opcode: u8

Operation code.

§aa: bool

Authoritative Answer flag.

§tc: bool

Truncation flag.

§rd: bool

Recursion Desired flag.

§ra: bool

Recursion Available flag.

§z: bool

Reserved (Z) flag.

§ad: bool

Authenticated Data flag (DNSSEC).

§cd: bool

Checking Disabled flag (DNSSEC).

§rcode: u8

Response code.

§questions: Vec<DnsQuestion>

Question section.

§answers: Vec<DnsResourceRecord>

Answer section.

§authorities: Vec<DnsResourceRecord>

Authority section.

§additionals: Vec<DnsResourceRecord>

Additional section.

§compress: bool

Whether to use DNS name compression when building.

Implementations§

Source§

impl DnsBuilder

Source

pub fn new() -> Self

Create a new DNS builder with default values (standard query with RD=1).

Source

pub fn query(qname: &str, qtype: u16) -> Self

Create a builder for a standard query.

Source

pub fn response() -> Self

Create a builder for a standard response.

Source

pub fn id(self, id: u16) -> Self

Source

pub fn qr(self, qr: bool) -> Self

Source

pub fn opcode(self, opcode: u8) -> Self

Source

pub fn aa(self, aa: bool) -> Self

Source

pub fn tc(self, tc: bool) -> Self

Source

pub fn rd(self, rd: bool) -> Self

Source

pub fn ra(self, ra: bool) -> Self

Source

pub fn z(self, z: bool) -> Self

Source

pub fn ad(self, ad: bool) -> Self

Source

pub fn cd(self, cd: bool) -> Self

Source

pub fn rcode(self, rcode: u8) -> Self

Source

pub fn compress(self, compress: bool) -> Self

Source

pub fn question(self, q: DnsQuestion) -> Self

Add a question to the question section.

Source

pub fn answer(self, rr: DnsResourceRecord) -> Self

Add a resource record to the answer section.

Source

pub fn authority(self, rr: DnsResourceRecord) -> Self

Add a resource record to the authority section.

Source

pub fn additional(self, rr: DnsResourceRecord) -> Self

Add a resource record to the additional section.

Source

pub fn build(&self) -> Vec<u8>

Build the DNS packet bytes.

Source

pub fn header_size(&self) -> usize

Get the minimum header size.

Trait Implementations§

Source§

impl Clone for DnsBuilder

Source§

fn clone(&self) -> DnsBuilder

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DnsBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DnsBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<DnsBuilder> for LayerStack

Source§

fn from(builder: DnsBuilder) -> Self

Converts to this type from the input type.
Source§

impl IntoLayerStackEntry for DnsBuilder

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V