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
impl RecordSet
Sourcepub fn new(name: Name, record_type: RecordType) -> Self
pub fn new(name: Name, record_type: RecordType) -> Self
Sourcepub fn from_record<R: RecordData>(name: Name, record: Record<R>) -> Self
pub fn from_record<R: RecordData>(name: Name, record: Record<R>) -> Self
Sourcepub fn name(&self) -> &Name
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
Sourcepub fn record_type(&self) -> RecordType
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
Sourcepub fn dns_class(&self) -> DNSClass
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
Sourcepub fn set_dns_class(&mut self, dns_class: DNSClass) -> &mut Self
pub fn set_dns_class(&mut self, dns_class: DNSClass) -> &mut Self
Sourcepub fn set_ttl(&mut self, ttl: TimeToLive) -> &mut Self
pub fn set_ttl(&mut self, ttl: TimeToLive) -> &mut Self
Sourcepub fn with_name(&self, name: Name) -> Self
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
Sourcepub fn ttl(&self) -> TimeToLive
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
Sourcepub fn serial(&self) -> SerialNumber
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
impl RecordSet
Sourcepub fn records(&self) -> impl Iterator<Item = &Record>
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
Sourcepub fn into_records(self) -> impl Iterator<Item = Record>
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
Sourcepub fn into_signed_records(self) -> impl Iterator<Item = Record>
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
Sourcepub fn signed_records(&self) -> impl Iterator<Item = &Record>
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
Sourcepub fn is_empty(&self) -> bool
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
Sourcepub fn len(&self) -> usize
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
Sourcepub fn rrsigs(&self) -> &[Record]
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
Sourcepub fn insert_rrsig(&mut self, rrsig: Record) -> Result<(), Mismatch>
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
Sourcepub fn clear_rrsigs(&mut self)
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.
Sourcepub fn push(&mut self, rdata: RData) -> Result<bool, Mismatch>
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
Sourcepub fn insert(
&mut self,
record: Record,
serial: SerialNumber,
) -> Result<bool, Mismatch>
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 insertserial- 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
Sourcepub fn remove(
&mut self,
record: &Record,
serial: SerialNumber,
) -> Result<bool, Mismatch>
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