Struct Record
pub struct Record<R = RData>where
R: RecordData,{ /* 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§
§impl Record
impl Record
pub fn update0(name: Name, ttl: u32, rr_type: RecordType) -> Record
pub fn update0(name: Name, ttl: u32, rr_type: RecordType) -> Record
Creates an update record with RDLENGTH=0
pub 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
§impl<R> Record<R>where
R: RecordData,
impl<R> Record<R>where
R: RecordData,
pub fn from_rdata(name: Name, ttl: u32, rdata: R) -> Record<R>
pub fn from_rdata(name: Name, ttl: u32, rdata: R) -> Record<R>
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
pub fn try_from(record: Record) -> Result<Record<R>, Record>
pub fn try_from(record: Record) -> Result<Record<R>, Record>
Attempts to convert the generic RData
based Record into this one with the interior R
pub fn into_record_of_rdata(self) -> Record
pub fn into_record_of_rdata(self) -> Record
Converts this Record into a generic version of RData
pub fn set_name(&mut self, name: Name) -> &mut Record<R>
pub fn set_name(&mut self, name: Name) -> &mut Record<R>
NAME a domain name to which this resource record pertains.
pub fn set_dns_class(&mut self, dns_class: DNSClass) -> &mut Record<R>
pub fn set_dns_class(&mut self, dns_class: DNSClass) -> &mut Record<R>
CLASS two octets which specify the class of the data in the
RDATA field.
pub fn set_ttl(&mut self, ttl: u32) -> &mut Record<R>
pub fn set_ttl(&mut self, ttl: u32) -> &mut Record<R>
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.
pub fn set_data(&mut self, rdata: R) -> &mut Record<R>
pub fn set_data(&mut self, rdata: R) -> &mut Record<R>
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.
pub fn record_type(&self) -> RecordType
pub fn record_type(&self) -> RecordType
Returns the type of the RecordData in the record
pub fn into_data(self) -> R
pub fn into_data(self) -> R
Returns the RData consuming the Record
pub fn into_parts(self) -> RecordParts
pub fn into_parts(self) -> RecordParts
Consumes Record
and returns its components
Trait Implementations§
§impl<'r> BinDecodable<'r> for Record
impl<'r> BinDecodable<'r> for Record
§fn read(decoder: &mut BinDecoder<'r>) -> Result<Record, ProtoError>
fn read(decoder: &mut BinDecoder<'r>) -> Result<Record, ProtoError>
parse a resource record line example: WARNING: the record_bytes is 100% consumed and destroyed in this parsing process
§fn from_bytes(bytes: &'r [u8]) -> Result<Self, ProtoError>
fn from_bytes(bytes: &'r [u8]) -> Result<Self, ProtoError>
§impl<R> BinEncodable for Record<R>where
R: RecordData,
impl<R> BinEncodable for Record<R>where
R: RecordData,
§fn emit(&self, encoder: &mut BinEncoder<'_>) -> Result<(), ProtoError>
fn emit(&self, encoder: &mut BinEncoder<'_>) -> Result<(), ProtoError>
§impl<R> Clone for Record<R>where
R: Clone + RecordData,
impl<R> Clone for Record<R>where
R: Clone + RecordData,
§impl<R> Debug for Record<R>where
R: Debug + RecordData,
impl<R> Debug for Record<R>where
R: Debug + RecordData,
§impl<R> Display for Record<R>where
R: RecordData,
RFC 1033, DOMAIN OPERATIONS GUIDE, November 1987
impl<R> Display for Record<R>where
R: RecordData,
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.
§impl<R> From<Record<R>> for RecordParts<R>where
R: RecordData,
impl<R> From<Record<R>> for RecordParts<R>where
R: RecordData,
§fn from(record: Record<R>) -> RecordParts<R>
fn from(record: Record<R>) -> RecordParts<R>
§impl IntoRecordSet for Record
impl IntoRecordSet for Record
§fn into_record_set(self) -> RecordSet
fn into_record_set(self) -> RecordSet
§impl Ord for Record
impl Ord for Record
§fn cmp(&self, other: &Record) -> Ordering
fn cmp(&self, other: &Record) -> 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,
§impl<R> PartialEq for Record<R>where
R: RecordData,
impl<R> PartialEq for Record<R>where
R: RecordData,
§fn eq(&self, other: &Record<R>) -> bool
fn eq(&self, other: &Record<R>) -> bool
Equality of 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
§impl PartialOrd for Record
impl PartialOrd for Record
§fn partial_cmp(&self, other: &Record) -> Option<Ordering>
fn partial_cmp(&self, other: &Record) -> 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<'a, R> TryFrom<&'a Record> for RecordRef<'a, R>where
R: RecordData,
impl<'a, R> TryFrom<&'a Record> for RecordRef<'a, R>where
R: RecordData,
impl<R> Eq for Record<R>where
R: Eq + RecordData,
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§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy
that returns Action::Follow
only if self
and other
return
Action::Follow
. Read more§impl<T, U> RamaTryFrom<T> for Uwhere
U: TryFrom<T>,
impl<T, U> RamaTryFrom<T> for Uwhere
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
fn rama_try_from(value: T) -> Result<U, <U as RamaTryFrom<T>>::Error>
§impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for Twhere
U: RamaTryFrom<T, CrateMarker>,
impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for Twhere
U: RamaTryFrom<T, CrateMarker>,
type Error = <U as RamaTryFrom<T, CrateMarker>>::Error
fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T, CrateMarker>>::Error>
§impl<T> ToSmolStr for T
impl<T> ToSmolStr for T
fn to_smolstr(&self) -> SmolStr
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string
, but without panic on OOM.