pub struct Record<R: RecordData = RData> { /* private fields */ }
Expand description
Resource records are storage value in DNS, into which all key/value pair data is stored.
§Generic type
R
- the RecordData type this resource record represents, if unknown at runtime use theRData
abstract enum type
RFC 1035, DOMAIN NAMES - IMPLEMENTATION AND SPECIFICATION, November 1987
4.1.3. Resource record format
The answer, authority, and additional sections all share the same
format: a variable number of resource records, where the number of
records is specified in the corresponding count field in the header.
Each resource record has the following format:
1 1 1 1 1 1
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| |
/ /
/ NAME /
| |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| TYPE |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| CLASS |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| TTL |
| |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| RDLENGTH |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
/ RDATA /
/ /
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
Implementations§
Source§impl Record
impl Record
Sourcepub fn update0(name: Name, ttl: u32, rr_type: RecordType) -> Self
pub fn update0(name: Name, ttl: u32, rr_type: RecordType) -> Self
Creates an update record with RDLENGTH=0
Sourcepub fn try_borrow<T>(&self) -> Option<RecordRef<'_, T>>where
T: RecordData,
pub fn try_borrow<T>(&self) -> Option<RecordRef<'_, T>>where
T: RecordData,
Tries the borrow this record as the specific record type, T
Source§impl<R: RecordData> Record<R>
impl<R: RecordData> Record<R>
Sourcepub fn from_rdata(name: Name, ttl: u32, rdata: R) -> Self
pub fn from_rdata(name: Name, ttl: u32, rdata: R) -> Self
Create a record with the specified initial values.
§Arguments
name
- name of the resource recordsttl
- time-to-live is the amount of time this record should be cached before refreshingrdata
- record data to associate with the Record
Sourcepub fn try_from(record: Record<RData>) -> Result<Self, Record<RData>>
pub fn try_from(record: Record<RData>) -> Result<Self, Record<RData>>
Attempts to convert the generic RData
based Record into this one with the interior R
Sourcepub fn into_record_of_rdata(self) -> Record<RData>
pub fn into_record_of_rdata(self) -> Record<RData>
Converts this Record into a generic version of RData
Sourcepub fn set_name(&mut self, name: Name) -> &mut Self
pub fn set_name(&mut self, name: Name) -> &mut Self
NAME a domain name to which this resource record pertains.
Sourcepub fn set_dns_class(&mut self, dns_class: DNSClass) -> &mut Self
pub fn set_dns_class(&mut self, dns_class: DNSClass) -> &mut Self
CLASS two octets which specify the class of the data in the
RDATA field.
Sourcepub fn set_ttl(&mut self, ttl: u32) -> &mut Self
pub fn set_ttl(&mut self, ttl: u32) -> &mut Self
TTL a 32 bit unsigned integer that specifies the time
interval (in seconds) that the resource record may be
cached before it should be discarded. Zero values are
interpreted to mean that the RR can only be used for the
transaction in progress, and should not be cached.
Sourcepub fn set_data(&mut self, rdata: R) -> &mut Self
pub fn set_data(&mut self, rdata: R) -> &mut Self
RDATA a variable length string of octets that describes the
resource. The format of this information varies
according to the TYPE and CLASS of the resource record.
For example, the if the TYPE is A and the CLASS is IN,
the RDATA field is a 4 octet ARPA Internet address.
Sourcepub fn set_mdns_cache_flush(&mut self, flag: bool) -> &mut Self
Available on crate feature mdns
only.
pub fn set_mdns_cache_flush(&mut self, flag: bool) -> &mut Self
mdns
only.Changes mDNS cache-flush bit See RFC 6762
Sourcepub fn set_proof(&mut self, proof: Proof) -> &mut Self
Available on crate feature dnssec
only.
pub fn set_proof(&mut self, proof: Proof) -> &mut Self
dnssec
only.Set the DNSSEC Proof for this record, after it’s been verified
Sourcepub fn record_type(&self) -> RecordType
pub fn record_type(&self) -> RecordType
Returns the type of the RecordData in the record
Sourcepub fn dns_class(&self) -> DNSClass
pub fn dns_class(&self) -> DNSClass
Returns the DNSClass of the Record, generally IN fro internet
Sourcepub fn into_parts(self) -> RecordParts
pub fn into_parts(self) -> RecordParts
Consumes Record
and returns its components
Sourcepub fn mdns_cache_flush(&self) -> bool
Available on crate feature mdns
only.
pub fn mdns_cache_flush(&self) -> bool
mdns
only.Returns if the mDNS cache-flush bit is set or not See RFC 6762
Trait Implementations§
Source§impl<'r> BinDecodable<'r> for Record<RData>
impl<'r> BinDecodable<'r> for Record<RData>
Source§fn read(decoder: &mut BinDecoder<'r>) -> Result<Self, ProtoError>
fn read(decoder: &mut BinDecoder<'r>) -> Result<Self, ProtoError>
parse a resource record line example: WARNING: the record_bytes is 100% consumed and destroyed in this parsing process
Source§fn from_bytes(bytes: &'r [u8]) -> Result<Self, ProtoError>
fn from_bytes(bytes: &'r [u8]) -> Result<Self, ProtoError>
Source§impl<R: RecordData> BinEncodable for Record<R>
impl<R: RecordData> BinEncodable for Record<R>
Source§fn emit(&self, encoder: &mut BinEncoder<'_>) -> Result<(), ProtoError>
fn emit(&self, encoder: &mut BinEncoder<'_>) -> Result<(), ProtoError>
Source§impl<'de, R> Deserialize<'de> for Record<R>where
R: Deserialize<'de> + RecordData,
impl<'de, R> Deserialize<'de> for Record<R>where
R: Deserialize<'de> + RecordData,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<R: RecordData> Display for Record<R>
impl<R: RecordData> Display for Record<R>
RFC 1033, DOMAIN OPERATIONS GUIDE, November 1987
RESOURCE RECORDS
Records in the zone data files are called resource records (RRs).
They are specified in RFC-883 and RFC-973. An RR has a standard
format as shown:
<name> [<ttl>] [<class>] <type> <data>
The record is divided into fields which are separated by white space.
<name>
The name field defines what domain name applies to the given
RR. In some cases the name field can be left blank and it will
default to the name field of the previous RR.
<ttl>
TTL stands for Time To Live. It specifies how long a domain
resolver should cache the RR before it throws it out and asks a
domain server again. See the section on TTL's. If you leave
the TTL field blank it will default to the minimum time
specified in the SOA record (described later).
<class>
The class field specifies the protocol group. If left blank it
will default to the last class specified.
<type>
The type field specifies what type of data is in the RR. See
the section on types.
<data>
The data field is defined differently for each type and class
of data. Popular RR data formats are described later.
Source§impl<R: RecordData> From<Record<R>> for RecordParts<R>
impl<R: RecordData> From<Record<R>> for RecordParts<R>
Source§impl IntoRecordSet for Record
impl IntoRecordSet for Record
Source§fn into_record_set(self) -> RecordSet
fn into_record_set(self) -> RecordSet
Source§impl Ord for Record
impl Ord for Record
Source§fn cmp(&self, other: &Self) -> Ordering
fn cmp(&self, other: &Self) -> Ordering
Canonical ordering as defined by RFC 4034, DNSSEC Resource Records, March 2005
6.2. Canonical RR Form
For the purposes of DNS security, the canonical form of an RR is the
wire format of the RR where:
1. every domain name in the RR is fully expanded (no DNS name
compression) and fully qualified;
2. all uppercase US-ASCII letters in the owner name of the RR are
replaced by the corresponding lowercase US-ASCII letters;
3. if the type of the RR is NS, MD, MF, CNAME, SOA, MB, MG, MR, PTR,
HINFO, MINFO, MX, HINFO, RP, AFSDB, RT, SIG, PX, NXT, NAPTR, KX,
SRV, DNAME, A6, RRSIG, or NSEC, all uppercase US-ASCII letters in
the DNS names contained within the RDATA are replaced by the
corresponding lowercase US-ASCII letters;
4. if the owner name of the RR is a wildcard name, the owner name is
in its original unexpanded form, including the "*" label (no
wildcard substitution); and
5. the RR's TTL is set to its original value as it appears in the
originating authoritative zone or the Original TTL field of the
covering RRSIG RR.
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<R: RecordData> PartialEq for Record<R>
impl<R: RecordData> PartialEq for Record<R>
Source§fn eq(&self, other: &Self) -> bool
fn eq(&self, other: &Self) -> bool
Equality or records, as defined by RFC 2136, DNS Update, April 1997
1.1.1. Two RRs are considered equal if their NAME, CLASS, TYPE,
RDLENGTH and RDATA fields are equal. Note that the time-to-live
(TTL) field is explicitly excluded from the comparison.
1.1.2. The rules for comparison of character strings in names are
specified in [RFC1035 2.3.3]. i.e. case insensitive
Source§impl PartialOrd for Record
impl PartialOrd for Record
Source§fn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
Canonical ordering as defined by RFC 4034, DNSSEC Resource Records, March 2005
6.2. Canonical RR Form
For the purposes of DNS security, the canonical form of an RR is the
wire format of the RR where:
1. every domain name in the RR is fully expanded (no DNS name
compression) and fully qualified;
2. all uppercase US-ASCII letters in the owner name of the RR are
replaced by the corresponding lowercase US-ASCII letters;
3. if the type of the RR is NS, MD, MF, CNAME, SOA, MB, MG, MR, PTR,
HINFO, MINFO, MX, HINFO, RP, AFSDB, RT, SIG, PX, NXT, NAPTR, KX,
SRV, DNAME, A6, RRSIG, or NSEC, all uppercase US-ASCII letters in
the DNS names contained within the RDATA are replaced by the
corresponding lowercase US-ASCII letters;
4. if the owner name of the RR is a wildcard name, the owner name is
in its original unexpanded form, including the "*" label (no
wildcard substitution); and
5. the RR's TTL is set to its original value as it appears in the
originating authoritative zone or the Original TTL field of the
covering RRSIG RR.
impl<R: Eq + RecordData> Eq for Record<R>
Auto Trait Implementations§
impl<R> Freeze for Record<R>where
R: Freeze,
impl<R> RefUnwindSafe for Record<R>where
R: RefUnwindSafe,
impl<R> Send for Record<R>where
R: Send,
impl<R> Sync for Record<R>where
R: Sync,
impl<R> Unpin for Record<R>where
R: Unpin,
impl<R> UnwindSafe for Record<R>where
R: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.