Skip to main content

RecordSet

Struct RecordSet 

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

A collection of like resource records.

The collection consists of a list of resource records of the same type, and a separate list of the singing records which secure these resource recrods.

The entire record set has a common TTL, and tracks the SOA Serial Number when it was last updated.

Implementations§

Source§

impl RecordSet

Source

pub fn new(name: Name, record_type: RecordType) -> Self

Create a new empty record set

Creates a new record set for the specified name and record type. Records can be added later using the insert method.

§Arguments
  • name - The DNS name for this record set
  • record_type - The DNS record type (A, AAAA, CNAME, etc.)
§Returns

A new empty record set

Source

pub fn from_record<R: RecordData>(name: Name, record: Record<R>) -> Self

Create a record set from a single record

Creates a new record set containing the specified record.

§Arguments
  • name - The DNS name for this record set
  • record - The initial record to include
§Returns

A new record set containing the specified record

Source

pub fn name(&self) -> &Name

Get the DNS name for this record set

Returns the fully qualified domain name that all records in this set apply to.

§Returns

A reference to the DNS name

Source

pub fn record_type(&self) -> RecordType

Get the record type for this record set

Returns the DNS record type (A, AAAA, CNAME, etc.) that all records in this set share.

§Returns

The DNS record type

Source

pub fn dns_class(&self) -> DNSClass

Get the DNS class for this record set

Returns the DNS class (typically IN for Internet) that all records in this set share.

§Returns

The DNS class

Source

pub fn set_dns_class(&mut self, dns_class: DNSClass) -> &mut Self

Set the DNS class for this record set

Updates the DNS class for all records in this set.

§Arguments
  • dns_class - The new DNS class
§Returns

A mutable reference to this record set for method chaining

Source

pub fn set_ttl(&mut self, ttl: TimeToLive) -> &mut Self

Set the Time To Live for all records in this set

Updates the TTL value for all records in this set, which determines how long DNS resolvers should cache these records.

§Arguments
  • ttl - The new TTL value
§Returns

A mutable reference to this record set for method chaining

Source

pub fn with_name(&self, name: Name) -> Self

Create a copy of this record set with a different name

Creates a new record set with the same records but a different DNS name. RRSIG signatures are cleared since they would be invalid for the new name.

§Arguments
  • name - The new DNS name for the copied record set
§Returns

A new record set with the specified name

Source

pub fn ttl(&self) -> TimeToLive

Get the Time To Live for this record set

Returns the TTL value which determines how long DNS resolvers should cache records from this set.

§Returns

The TTL value

Source

pub fn serial(&self) -> SerialNumber

Get the serial number for this record set

Returns the serial number that tracks the last update to this record set.

§Returns

The serial number

Source§

impl RecordSet

Source

pub fn rrkey(&self) -> RrKey

Record Lookup Key for this Record Set

Source

pub fn records(&self) -> impl Iterator<Item = &Record>

Get an iterator over all records in this set

Returns an iterator that yields all DNS records in the set, excluding any RRSIG signatures.

§Returns

An iterator over the records

Source

pub fn into_records(self) -> impl Iterator<Item = Record>

Convert this record set into an iterator over its records

Consumes the record set and returns an iterator over all DNS records, excluding any RRSIG signatures.

§Returns

An iterator that takes ownership of the records

Source

pub fn into_signed_records(self) -> impl Iterator<Item = Record>

Convert this record set into an iterator over all records and signatures

Consumes the record set and returns an iterator over all DNS records and their RRSIG signatures.

§Returns

An iterator that takes ownership of all records and signatures

Source

pub fn signed_records(&self) -> impl Iterator<Item = &Record>

Get an iterator over all records and signatures in this set

Returns an iterator that yields all DNS records in the set along with any RRSIG signatures.

§Returns

An iterator over all records and signatures

Source

pub fn is_empty(&self) -> bool

Check if this record set is empty

Returns true if the record set contains no DNS records. RRSIG signatures are not counted.

§Returns

true if the record set contains no records

Source

pub fn len(&self) -> usize

Get the number of records in this set

Returns the count of DNS records in the set. RRSIG signatures are not counted.

§Returns

The number of records

Source

pub fn rrsigs(&self) -> &[Record]

Get all RRSIG signatures for this record set

Returns a slice containing all RRSIG records that provide DNSSEC signatures for the records in this set.

§Returns

A slice of RRSIG records

Source

pub fn insert_rrsig(&mut self, rrsig: Record) -> Result<(), Mismatch>

Insert an RRSIG signature for this record set

Adds a DNSSEC signature (RRSIG) to this record set. The signature must cover the correct record type. Multiple signatures can be added.

§Arguments
  • rrsig - The RRSIG record to add
§Returns

Ok(()) on success, or an error if the signature is invalid

§Errors

Returns an error if the RRSIG doesn’t cover the correct record type

Source

pub fn clear_rrsigs(&mut self)

Clear all RRSIG signatures from this record set

Removes all DNSSEC signatures. This is useful when the record set is updated or when cryptographic keys are rotated.

Source

pub fn push(&mut self, rdata: RData) -> Result<bool, Mismatch>

Add a new record to this record set

Creates a new record with the specified resource data and adds it to this record set. The record will use the set’s name and TTL.

§Arguments
  • rdata - The resource data for the new record
§Returns

Ok(true) if the record was added, Ok(false) if it was a duplicate, or an error if the record is incompatible with this set

§Errors

Returns an error if the record type doesn’t match this set

Source

pub fn insert( &mut self, record: Record, serial: SerialNumber, ) -> Result<bool, Mismatch>

Insert a record into this record set

Adds a record to this set, handling deduplication and special rules for different record types (SOA, CNAME, etc.). Updates the serial number if the record set is modified.

§Arguments
  • record - The record to insert
  • serial - The serial number for this update
§Returns

Ok(true) if the record set was modified, Ok(false) if no change occurred, or an error if the record is incompatible

§Errors

Returns an error if the record’s name or type doesn’t match this set

Source

pub fn remove( &mut self, record: &Record, serial: SerialNumber, ) -> Result<bool, Mismatch>

Remove a record from this record set

Removes records matching the specified record’s resource data. Some record types (SOA, last NS) have special protection against removal.

§Arguments
  • record - The record to remove (matched by resource data)
  • serial - The serial number for this update
§Returns

Ok(true) if the record set was modified, Ok(false) if no change occurred, or an error if the record is incompatible

§Errors

Returns an error if the record’s name or type doesn’t match this set

Trait Implementations§

Source§

impl AsHickory for RecordSet

Source§

type Hickory = RecordSet

The corresponding hickory-dns type
Source§

fn as_hickory(&self) -> Self::Hickory

Convert this type to its hickory-dns equivalent Read more
Source§

impl Clone for RecordSet

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RecordSet

Source§

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

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

impl From<Record> for RecordSet

Source§

fn from(record: Record) -> Self

Converts to this type from the input type.
Source§

impl From<RecordSet> for RecordSet

Source§

fn from(value: RecordSet) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for RecordSet

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for RecordSet

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> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more