Struct OptBuilder

Source
pub struct OptBuilder { /* private fields */ }
Expand description

Builds an OPT record as part of the additional section of a DNS message,

This type can be constructed by calling the opt method on any other builder type. See the module documentation for on overview on building messages.

As OPT records are part of the additional section, this type will, when constructed proceed to this section and append an OPT record without any options to it. Options can be appened via the push method.

The type also deref-muts to OptHeader allowing you to modify the header’s fields such as setting the UDP payload size or the DO bit.

Once you have adjusted the OPT record to your liking, you can return to the additional section via additional. Note, however, that the OPT record should be the last record except for a possible TSIG record. You can also finish the message via finish or freeze.

Implementations§

Source§

impl OptBuilder

Source

pub fn push<O: OptData>(&mut self, option: &O) -> Result<(), ShortBuf>

Pushes an option to the OPT record.

The method is generic over anything that implements the OptData trait representing an option. Alternatively, most of these types provide a push associated function that allows to construct an option directly into a record from its data.

Source

pub fn additional(self) -> AdditionalBuilder

Completes the OPT record and returns to the additional section builder.

Methods from Deref<Target = OptHeader>§

Source

pub fn udp_payload_size(&self) -> u16

Source

pub fn set_udp_payload_size(&mut self, value: u16)

Source

pub fn rcode(&self, header: Header) -> OptRcode

Source

pub fn set_rcode(&mut self, rcode: OptRcode)

Source

pub fn version(&self) -> u8

Source

pub fn set_version(&mut self, version: u8)

Source

pub fn dnssec_ok(&self) -> bool

Source

pub fn set_dnssec_ok(&mut self, value: bool)

Trait Implementations§

Source§

impl Clone for OptBuilder

Source§

fn clone(&self) -> OptBuilder

Returns a copy 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 OptBuilder

Source§

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

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

impl Deref for OptBuilder

Source§

type Target = OptHeader

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for OptBuilder

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl SectionBuilder for OptBuilder

Source§

fn into_target(self) -> MessageTarget

Converts into target
Source§

fn get_target(&self) -> &MessageTarget

Returns message target
Source§

fn get_target_mut(&mut self) -> &mut MessageTarget

Returns message target
Source§

fn set_limit(&mut self, limit: usize)

Updates the message’s size limit. Read more
Source§

fn header(&self) -> &Header

Returns a reference to the messages header.
Source§

fn header_mut(&mut self) -> &mut Header

Returns a mutable reference to the messages header.
Source§

fn preview(&self) -> &[u8]

Returns a reference to the message assembled so far. Read more
Source§

fn prelude(&self) -> &[u8]

Returns a reference to the slice preceeding the message. Read more
Source§

fn prelude_mut(&mut self) -> &mut [u8]

Returns a mutable reference to the slice preceeding the message.
Source§

fn finish(self) -> BytesMut

Finishes the message and returns the underlying bytes buffer. Read more
Source§

fn freeze(self) -> Message

Finishes the message and returns the resulting bytes value. Read more
Source§

fn snapshot(&self) -> Snapshot<Self>

Returns a snapshot indicating the current state of the message. Read more
Source§

fn rewind(&mut self, snapshot: &Snapshot<Self>)

Rewinds the message to the state it had at snapshot. Read more

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.