Skip to main content

DnsQuestion

Struct DnsQuestion 

Source
pub struct DnsQuestion {
    pub qname: DnsName,
    pub qtype: u16,
    pub qclass: u16,
}
Expand description

A DNS question record.

Fields§

§qname: DnsName

The domain name being queried.

§qtype: u16

The query type (e.g., A=1, AAAA=28, MX=15).

§qclass: u16

The query class (typically IN=1). For mDNS, bit 15 is the unicast-response flag.

Implementations§

Source§

impl DnsQuestion

Source

pub fn new(qname: DnsName) -> Self

Create a new question with default type A and class IN.

Source

pub fn from_name(name: &str) -> Result<Self, FieldError>

Create a question from a domain name string.

Source

pub fn unicast_response(&self) -> bool

Whether this is an mDNS unicast-response question.

Source

pub fn actual_class(&self) -> u16

Get the actual class (without the mDNS unicast-response bit).

Source

pub fn set_unicast_response(&mut self, unicast: bool)

Set the mDNS unicast-response flag.

Source

pub fn parse(packet: &[u8], offset: usize) -> Result<(Self, usize), FieldError>

Parse a question from wire format.

packet is the full DNS packet (for pointer decompression). offset is the start of the question record.

Returns the parsed question and bytes consumed.

Source

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

Build the question record without compression.

Source

pub fn build_compressed( &self, current_offset: usize, compression_map: &mut HashMap<String, u16>, ) -> Vec<u8>

Build with DNS name compression.

Source

pub fn summary(&self) -> String

Human-readable summary.

Trait Implementations§

Source§

impl Clone for DnsQuestion

Source§

fn clone(&self) -> DnsQuestion

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 DnsQuestion

Source§

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

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

impl Default for DnsQuestion

Source§

fn default() -> Self

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

impl PartialEq for DnsQuestion

Source§

fn eq(&self, other: &DnsQuestion) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for DnsQuestion

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