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

Creates a new value with all counters set to zero.

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.

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.

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

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

Sets the counts to those from counts.

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.

Sets the value of the QDCOUNT field.

Increases the value of the QDCOUNT field by one.

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

Decreases the value of the QDCOUNT field by one.

Panics

This method panics if the count is already zero.

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.

Sets the value of the ANCOUNT field.

Increases the value of the ANCOUNT field by one.

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

Decreases the value of the ANCOUNT field by one.

Panics

This method panics if the count is already zero.

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.

Sets the value of the NSCOUNT field.

Increases the value of the NSCOUNT field by one.

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

Decreases the value of the NSCOUNT field by one.

Panics

This method panics if the count is already zero.

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.

Sets the value of the ARCOUNT field.

Increases the value of the ARCOUNT field by one.

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

Decreases the value of the ARCOUNT field by one.

Panics

This method panics if the count is already zero.

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.

Sets the value of the ZOCOUNT field.

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.

Sete the value of the PRCOUNT field.

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.

Sets the value of the UPCOUNT field.

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.

Sets the value of the ADCOUNT field.

Trait Implementations

Converts this type into a mutable reference of the (usually inferred) input type.

Converts this type into a shared reference of the (usually inferred) input type.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Performs the conversion.

The resulting type after obtaining ownership.

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.