pub struct Record { /* private fields */ }
Expand description
Resource records are storage value in DNS, into which all key/value pair data is stored.
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
sourceimpl Record
impl Record
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a default record, use the setters to build a more useful object.
There are no optional elements in this object, defaults are an empty name, type A, class IN, ttl of 0 and the 0.0.0.0 ip address.
sourcepub fn with(name: Name, rr_type: RecordType, ttl: u32) -> Self
pub fn with(name: Name, rr_type: RecordType, ttl: u32) -> Self
Create a record with the specified initial values.
Arguments
name
- name of the resource recordsrr_type
- the record typettl
- time-to-live is the amount of time this record should be cached before refreshing
sourcepub fn from_rdata(name: Name, ttl: u32, rdata: RData) -> Self
pub fn from_rdata(name: Name, ttl: u32, rdata: RData) -> 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 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_rr_type(&mut self, rr_type: RecordType) -> &mut Self
pub fn set_rr_type(&mut self, rr_type: RecordType) -> &mut Self
TYPE two octets containing one of the RR type codes. This
field specifies the meaning of the data in the RDATA
field.
sourcepub fn set_record_type(&mut self, rr_type: RecordType) -> &mut Self
pub fn set_record_type(&mut self, rr_type: RecordType) -> &mut Self
TYPE two octets containing one of the RR type codes. This
field specifies the meaning of the data in the RDATA
field.
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_rdata(&mut self, rdata: RData) -> &mut Self
👎Deprecated: use Record::set_data
instead
pub fn set_rdata(&mut self, rdata: RData) -> &mut Self
use Record::set_data
instead
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_data(&mut self, rdata: Option<RData>) -> &mut Self
pub fn set_data(&mut self, rdata: Option<RData>) -> &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 rr_type(&self) -> RecordType
pub fn rr_type(&self) -> RecordType
Returns the type of the RData in the record
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 rdata(&self) -> &RData
👎Deprecated: use Record::data
instead
pub fn rdata(&self) -> &RData
use Record::data
instead
Returns the Record Data, i.e. the record information
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
sourcepub fn data_mut(&mut self) -> Option<&mut RData>
pub fn data_mut(&mut self) -> Option<&mut RData>
Returns a mutable reference to the Record Data
sourcepub fn into_parts(self) -> RecordParts
pub fn into_parts(self) -> RecordParts
Consumes Record
and returns its components
Trait Implementations
sourceimpl<'r> BinDecodable<'r> for Record
impl<'r> BinDecodable<'r> for Record
sourcefn read(decoder: &mut BinDecoder<'r>) -> ProtoResult<Self>
fn read(decoder: &mut BinDecoder<'r>) -> ProtoResult<Self>
parse a resource record line example: WARNING: the record_bytes is 100% consumed and destroyed in this parsing process
sourcefn from_bytes(bytes: &'r [u8]) -> ProtoResult<Self>
fn from_bytes(bytes: &'r [u8]) -> ProtoResult<Self>
Returns the object in binary form
sourceimpl BinEncodable for Record
impl BinEncodable for Record
sourcefn emit(&self, encoder: &mut BinEncoder<'_>) -> ProtoResult<()>
fn emit(&self, encoder: &mut BinEncoder<'_>) -> ProtoResult<()>
Write the type to the stream
sourcefn to_bytes(&self) -> ProtoResult<Vec<u8>>
fn to_bytes(&self) -> ProtoResult<Vec<u8>>
Returns the object in binary form
sourceimpl<'de> Deserialize<'de> for Record
impl<'de> Deserialize<'de> for Record
sourcefn 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>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Display for Record
impl Display for Record
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.
sourceimpl From<Record> for RecordParts
impl From<Record> for RecordParts
sourceimpl IntoRecordSet for Record
impl IntoRecordSet for Record
sourcefn into_record_set(self) -> RecordSet
fn into_record_set(self) -> RecordSet
use From/Into
Performs the conversion to a RecordSet
sourceimpl Ord for Record
impl Ord for Record
sourcefn 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 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialEq<Record> for Record
impl PartialEq<Record> for Record
sourcefn 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
sourceimpl PartialOrd<Record> for Record
impl PartialOrd<Record> for Record
sourcefn 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.
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Eq for Record
impl StructuralEq for Record
Auto Trait Implementations
impl RefUnwindSafe for Record
impl Send for Record
impl Sync for Record
impl Unpin for Record
impl UnwindSafe for Record
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more