[][src]Struct domain::base::header::HeaderCounts

pub struct HeaderCounts { /* fields omitted */ }

The section count part of the header section of a DNS message.

This part consists of four 16 bit counters for the number of entries in the four sections of a DNS message. The type contains the sequence of these for values in wire format, i.e., in network byte order.

The counters are arranged in the same order as the sections themselves: QDCOUNT for the question section, ANCOUNT for the answer section, NSCOUNT for the authority section, and ARCOUNT for the additional section. These are defined in RFC 1035.

Like with the other header part, you can create an owned value via the new method or the Default trait or can get a reference to the value atop a message slice via for_message_slice or for_message_slice_mut.

For each field there are three methods for getting, setting, and incrementing.

RFC 2136 defines the UPDATE method and reuses the four section for different purposes. Here the counters are ZOCOUNT for the zone section, PRCOUNT for the prerequisite section, UPCOUNT for the update section, and ADCOUNT for the additional section. The type has convenience methods for these fields as well so you don’t have to remember which is which.

Implementations

impl HeaderCounts[src]

pub fn new() -> Self[src]

Creates a new value with all counters set to zero.

pub fn for_message_slice(message: &[u8]) -> &Self[src]

Creates a header counts reference from the octets slice of a message.

The slice message mut be the whole message, i.e., start with the bytes of the Header.

Panics

This function panics if the octets slice is shorter than 24 octets.

pub fn for_message_slice_mut(message: &mut [u8]) -> &mut Self[src]

Creates a mutable counts reference from the octets slice of a message.

The slice message mut be the whole message, i.e., start with the bytes of the Header.

Panics

This function panics if the octets slice is shorter than 24 octets.

pub fn as_slice(&self) -> &[u8][src]

Returns a reference to the raw octets slice of the header counts.

pub fn as_slice_mut(&mut self) -> &mut [u8][src]

Returns a mutable reference to the octets slice of the header counts.

pub fn set(&mut self, counts: HeaderCounts)[src]

Sets the counts to those from counts.

impl HeaderCounts[src]

pub fn qdcount(self) -> u16[src]

Returns the value of the QDCOUNT field.

This field contains the number of questions in the first section of the message, normally the question section.

pub fn set_qdcount(&mut self, value: u16)[src]

Sets the value of the QDCOUNT field.

pub fn inc_qdcount(&mut self) -> Result<(), ShortBuf>[src]

Increases the value of the QDCOUNT field by one.

If increasing the counter would result in an overflow, returns an error.

pub fn dec_qdcount(&mut self)[src]

Decreases the value of the QDCOUNT field by one.

Panics

This method panics if the count is already zero.

pub fn ancount(self) -> u16[src]

Returns the value of the ANCOUNT field.

This field contains the number of resource records in the second section of the message, normally the answer section.

pub fn set_ancount(&mut self, value: u16)[src]

Sets the value of the ANCOUNT field.

pub fn inc_ancount(&mut self) -> Result<(), ShortBuf>[src]

Increases the value of the ANCOUNT field by one.

If increasing the counter would result in an overflow, returns an error.

pub fn dec_ancount(&mut self)[src]

Decreases the value of the ANCOUNT field by one.

Panics

This method panics if the count is already zero.

pub fn nscount(self) -> u16[src]

Returns the value of the NSCOUNT field.

This field contains the number of resource records in the third section of the message, normally the authority section.

pub fn set_nscount(&mut self, value: u16)[src]

Sets the value of the NSCOUNT field.

pub fn inc_nscount(&mut self) -> Result<(), ShortBuf>[src]

Increases the value of the NSCOUNT field by one.

If increasing the counter would result in an overflow, returns an error.

pub fn dec_nscount(&mut self)[src]

Decreases the value of the NSCOUNT field by one.

Panics

This method panics if the count is already zero.

pub fn arcount(self) -> u16[src]

Returns the value of the ARCOUNT field.

This field contains the number of resource records in the fourth section of the message, normally the additional section.

pub fn set_arcount(&mut self, value: u16)[src]

Sets the value of the ARCOUNT field.

pub fn inc_arcount(&mut self) -> Result<(), ShortBuf>[src]

Increases the value of the ARCOUNT field by one.

If increasing the counter would result in an overflow, returns an error.

pub fn dec_arcount(&mut self)[src]

Decreases the value of the ARCOUNT field by one.

Panics

This method panics if the count is already zero.

pub fn zocount(self) -> u16[src]

Returns the value of the ZOCOUNT field.

This is the same as the qdcount(). It is used in UPDATE queries where the first section is the zone section.

pub fn set_zocount(&mut self, value: u16)[src]

Sets the value of the ZOCOUNT field.

pub fn prcount(self) -> u16[src]

Returns the value of the PRCOUNT field.

This is the same as the ancount(). It is used in UPDATE queries where the first section is the prerequisite section.

pub fn set_prcount(&mut self, value: u16)[src]

Sete the value of the PRCOUNT field.

pub fn upcount(self) -> u16[src]

Returns the value of the UPCOUNT field.

This is the same as the nscount(). It is used in UPDATE queries where the first section is the update section.

pub fn set_upcount(&mut self, value: u16)[src]

Sets the value of the UPCOUNT field.

pub fn adcount(self) -> u16[src]

Returns the value of the ADCOUNT field.

This is the same as the arcount(). It is used in UPDATE queries where the first section is the additional section.

pub fn set_adcount(&mut self, value: u16)[src]

Sets the value of the ADCOUNT field.

Trait Implementations

impl AsMut<HeaderCounts> for HeaderSection[src]

impl AsRef<HeaderCounts> for HeaderSection[src]

impl Clone for HeaderCounts[src]

impl Copy for HeaderCounts[src]

impl Debug for HeaderCounts[src]

impl Default for HeaderCounts[src]

impl Eq for HeaderCounts[src]

impl PartialEq<HeaderCounts> for HeaderCounts[src]

impl StructuralEq for HeaderCounts[src]

impl StructuralPartialEq for HeaderCounts[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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