pub struct Zone {
apex: DomainName,
soa: Option<SOA>,
records: ZoneRecords,
}
Expand description
A zone is a collection of records all belonging to the same domain name.
Fields§
§apex: DomainName
The domain name which the records all belong to.
soa: Option<SOA>
The SOA record for this zone, if it is authoritative.
records: ZoneRecords
Records. These are indexed by label, with the labels relative to the apex. For example, if the apex is “barrucadu.co.uk”, then records for “www.barrucadu.co.uk” would be indexed under “www”.
Implementations§
Source§impl Zone
impl Zone
pub fn serialise(&self) -> String
Sourcefn serialise_domain(&self, name: &DomainName) -> String
fn serialise_domain(&self, name: &DomainName) -> String
Serialise a domain name: dotted string format, with the apex chopped off if this is an authoritative zone (unless the apex is the root domain, because that’s only a single character long so we may as well show it).
Sourcepub fn serialise_rdata(&self, rtype_with_data: &RecordTypeWithData) -> String
pub fn serialise_rdata(&self, rtype_with_data: &RecordTypeWithData) -> String
Serialise the RDATA, with domains displayed relative to the apex (if authoritative).
Source§impl Zone
impl Zone
Sourcepub fn new(apex: DomainName, soa: Option<SOA>) -> Self
pub fn new(apex: DomainName, soa: Option<SOA>) -> Self
Construct a new zone.
If there is a SOA
value, it is inserted as an RR at the root
of the zone.
Sourcepub fn get_apex(&self) -> &DomainName
pub fn get_apex(&self) -> &DomainName
Returns the apex domain.
Returns true if the zone is authoritative.
Sourcepub fn soa_rr(&self) -> Option<ResourceRecord>
pub fn soa_rr(&self) -> Option<ResourceRecord>
Returns the SOA RR if the zone is authoritative.
Sourcepub fn resolve(&self, name: &DomainName, qtype: QueryType) -> Option<ZoneResult>
pub fn resolve(&self, name: &DomainName, qtype: QueryType) -> Option<ZoneResult>
Resolve a query. Returns None
if the domain is not a
subdomain of the apex.
This corresponds to step 3 of the standard nameserver algorithm (see section 4.3.2 of RFC 1034).
Sourcepub fn insert(
&mut self,
name: &DomainName,
rtype_with_data: RecordTypeWithData,
ttl: u32,
)
pub fn insert( &mut self, name: &DomainName, rtype_with_data: RecordTypeWithData, ttl: u32, )
Insert a record for a domain. This domain MUST be a subdomain of the apex.
Note that, for authoritative zones, the SOA minimum
field is
a lower bound on the TTL of any RR in the zone. So if this
TTL is lower, it will be raised.
Sourcepub fn insert_wildcard(
&mut self,
name: &DomainName,
rtype_with_data: RecordTypeWithData,
ttl: u32,
)
pub fn insert_wildcard( &mut self, name: &DomainName, rtype_with_data: RecordTypeWithData, ttl: u32, )
Insert a wildcard record for a domain. This domain MUST be a subdomain of the apex.
Note that, for authoritative zones, the SOA minimum
field is
a lower bound on the TTL of any RR in the zone. So if this
TTL is lower, it will be raised.
Sourcepub fn relative_domain<'a>(&self, name: &'a DomainName) -> Option<&'a [Label]>
pub fn relative_domain<'a>(&self, name: &'a DomainName) -> Option<&'a [Label]>
Take a domain and chop off the suffix corresponding to the apex of this zone.
Returns None
if the given domain does not match the apex.
Sourcepub fn actual_ttl(&self, ttl: u32) -> u32
pub fn actual_ttl(&self, ttl: u32) -> u32
If this zone is authoritative, and the given TTL is below the
SOA minimum
field, returns the SOA minimum
field.
Otherwise returns the given TTL.
Sourcepub fn merge(&mut self, other: Zone) -> Result<(), (DomainName, DomainName)>
pub fn merge(&mut self, other: Zone) -> Result<(), (DomainName, DomainName)>
Sourcepub fn all_records(&self) -> HashMap<&DomainName, Vec<&ZoneRecord>>
pub fn all_records(&self) -> HashMap<&DomainName, Vec<&ZoneRecord>>
Return all the records in the zone.
Sourcepub fn all_wildcard_records(&self) -> HashMap<&DomainName, Vec<&ZoneRecord>>
pub fn all_wildcard_records(&self) -> HashMap<&DomainName, Vec<&ZoneRecord>>
Return all the wildcard records in the zone.