Struct domain::base::header::HeaderCounts
source · pub struct HeaderCounts { /* private fields */ }
Expand description
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§
source§impl HeaderCounts
impl HeaderCounts
§Creation and Conversion
sourcepub fn for_message_slice(message: &[u8]) -> &Self
pub fn for_message_slice(message: &[u8]) -> &Self
sourcepub fn for_message_slice_mut(message: &mut [u8]) -> &mut Self
pub fn for_message_slice_mut(message: &mut [u8]) -> &mut Self
sourcepub fn as_slice(&self) -> &[u8] ⓘ
pub fn as_slice(&self) -> &[u8] ⓘ
Returns a reference to the raw octets slice of the header counts.
sourcepub fn as_slice_mut(&mut self) -> &mut [u8] ⓘ
pub fn as_slice_mut(&mut self) -> &mut [u8] ⓘ
Returns a mutable reference to the octets slice of the header counts.
sourcepub fn set(&mut self, counts: HeaderCounts)
pub fn set(&mut self, counts: HeaderCounts)
Sets the counts to those from counts
.
source§impl HeaderCounts
impl HeaderCounts
§Field Access
sourcepub fn qdcount(self) -> u16
pub fn qdcount(self) -> u16
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.
sourcepub fn set_qdcount(&mut self, value: u16)
pub fn set_qdcount(&mut self, value: u16)
Sets the value of the QDCOUNT field.
sourcepub fn inc_qdcount(&mut self) -> Result<(), CountOverflow>
pub fn inc_qdcount(&mut self) -> Result<(), CountOverflow>
Increases the value of the QDCOUNT field by one.
If increasing the counter would result in an overflow, returns an error.
sourcepub fn dec_qdcount(&mut self)
pub fn dec_qdcount(&mut self)
Decreases the value of the QDCOUNT field by one.
§Panics
This method panics if the count is already zero.
sourcepub fn ancount(self) -> u16
pub fn ancount(self) -> u16
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.
sourcepub fn set_ancount(&mut self, value: u16)
pub fn set_ancount(&mut self, value: u16)
Sets the value of the ANCOUNT field.
sourcepub fn inc_ancount(&mut self) -> Result<(), CountOverflow>
pub fn inc_ancount(&mut self) -> Result<(), CountOverflow>
Increases the value of the ANCOUNT field by one.
If increasing the counter would result in an overflow, returns an error.
sourcepub fn dec_ancount(&mut self)
pub fn dec_ancount(&mut self)
Decreases the value of the ANCOUNT field by one.
§Panics
This method panics if the count is already zero.
sourcepub fn nscount(self) -> u16
pub fn nscount(self) -> u16
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.
sourcepub fn set_nscount(&mut self, value: u16)
pub fn set_nscount(&mut self, value: u16)
Sets the value of the NSCOUNT field.
sourcepub fn inc_nscount(&mut self) -> Result<(), CountOverflow>
pub fn inc_nscount(&mut self) -> Result<(), CountOverflow>
Increases the value of the NSCOUNT field by one.
If increasing the counter would result in an overflow, returns an error.
sourcepub fn dec_nscount(&mut self)
pub fn dec_nscount(&mut self)
Decreases the value of the NSCOUNT field by one.
§Panics
This method panics if the count is already zero.
sourcepub fn arcount(self) -> u16
pub fn arcount(self) -> u16
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.
sourcepub fn set_arcount(&mut self, value: u16)
pub fn set_arcount(&mut self, value: u16)
Sets the value of the ARCOUNT field.
sourcepub fn inc_arcount(&mut self) -> Result<(), CountOverflow>
pub fn inc_arcount(&mut self) -> Result<(), CountOverflow>
Increases the value of the ARCOUNT field by one.
If increasing the counter would result in an overflow, returns an error.
sourcepub fn dec_arcount(&mut self)
pub fn dec_arcount(&mut self)
Decreases the value of the ARCOUNT field by one.
§Panics
This method panics if the count is already zero.
sourcepub fn zocount(self) -> u16
pub fn zocount(self) -> u16
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.
sourcepub fn set_zocount(&mut self, value: u16)
pub fn set_zocount(&mut self, value: u16)
Sets the value of the ZOCOUNT field.
sourcepub fn prcount(self) -> u16
pub fn prcount(self) -> u16
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.
sourcepub fn set_prcount(&mut self, value: u16)
pub fn set_prcount(&mut self, value: u16)
Sete the value of the PRCOUNT field.
sourcepub fn upcount(self) -> u16
pub fn upcount(self) -> u16
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.
sourcepub fn set_upcount(&mut self, value: u16)
pub fn set_upcount(&mut self, value: u16)
Sets the value of the UPCOUNT field.
sourcepub fn adcount(self) -> u16
pub fn adcount(self) -> u16
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.
sourcepub fn set_adcount(&mut self, value: u16)
pub fn set_adcount(&mut self, value: u16)
Sets the value of the ADCOUNT field.
Trait Implementations§
source§impl AsMut<HeaderCounts> for HeaderSection
impl AsMut<HeaderCounts> for HeaderSection
source§fn as_mut(&mut self) -> &mut HeaderCounts
fn as_mut(&mut self) -> &mut HeaderCounts
source§impl AsRef<HeaderCounts> for HeaderSection
impl AsRef<HeaderCounts> for HeaderSection
source§fn as_ref(&self) -> &HeaderCounts
fn as_ref(&self) -> &HeaderCounts
source§impl Clone for HeaderCounts
impl Clone for HeaderCounts
source§fn clone(&self) -> HeaderCounts
fn clone(&self) -> HeaderCounts
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for HeaderCounts
impl Debug for HeaderCounts
source§impl Default for HeaderCounts
impl Default for HeaderCounts
source§fn default() -> HeaderCounts
fn default() -> HeaderCounts
source§impl PartialEq for HeaderCounts
impl PartialEq for HeaderCounts
source§fn eq(&self, other: &HeaderCounts) -> bool
fn eq(&self, other: &HeaderCounts) -> bool
self
and other
values to be equal, and is used
by ==
.