Struct hickory_proto::rr::resource::Record

source ·
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 the RData 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

source

pub fn update0(name: Name, ttl: u32, rr_type: RecordType) -> Self

Creates an update record with RDLENGTH=0

source

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>

source

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 records
  • ttl - time-to-live is the amount of time this record should be cached before refreshing
  • rdata - record data to associate with the Record
source

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

source

pub fn into_record_of_rdata(self) -> Record<RData>

Converts this Record into a generic version of RData

source

pub fn set_name(&mut self, name: Name) -> &mut Self

NAME            a domain name to which this resource record pertains.
source

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.
source

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.
source

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.
source

pub fn set_mdns_cache_flush(&mut self, flag: bool) -> &mut Self

Available on crate feature mdns only.

Changes mDNS cache-flush bit See RFC 6762

source

pub fn set_proof(&mut self, proof: Proof) -> &mut Self

Available on crate feature dnssec only.

Set the DNSSEC Proof for this record, after it’s been verified

source

pub fn name(&self) -> &Name

Returns the name of the record

source

pub fn record_type(&self) -> RecordType

Returns the type of the RecordData in the record

source

pub fn dns_class(&self) -> DNSClass

Returns the DNSClass of the Record, generally IN fro internet

source

pub fn ttl(&self) -> u32

Returns the time-to-live of the record, for caching purposes

source

pub fn data(&self) -> &R

Returns the Record Data, i.e. the record information

source

pub fn data_mut(&mut self) -> &mut R

Returns a mutable reference to the Record Data

source

pub fn into_data(self) -> R

Returns the RData consuming the Record

source

pub fn into_parts(self) -> RecordParts

Consumes Record and returns its components

source

pub fn mdns_cache_flush(&self) -> bool

Available on crate feature mdns only.

Returns if the mDNS cache-flush bit is set or not See RFC 6762

source

pub fn proof(&self) -> Proof

Available on crate feature dnssec only.

The Proof of DNSSEC validation for this record, this is only valid if some form of validation has occurred

Trait Implementations§

source§

impl<'r> BinDecodable<'r> for Record<RData>

source§

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

source§

fn from_bytes(bytes: &'r [u8]) -> ProtoResult<Self>

Returns the object in binary form
source§

impl<R: RecordData> BinEncodable for Record<R>

source§

fn emit(&self, encoder: &mut BinEncoder<'_>) -> ProtoResult<()>

Write the type to the stream
source§

fn to_bytes(&self) -> ProtoResult<Vec<u8>>

Returns the object in binary form
source§

impl<R: Clone + RecordData> Clone for Record<R>

source§

fn clone(&self) -> Record<R>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<R: Debug + RecordData> Debug for Record<R>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

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>,

Deserialize this value from the given Serde deserializer. Read more
source§

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§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<'a> From<&'a Edns> for Record

source§

fn from(value: &'a Edns) -> Self

This returns a Resource Record that is formatted for Edns(0). Note: the rcode_high value is only part of the rcode, the rest is part of the base

source§

impl<'a> From<&'a Record> for Edns

source§

fn from(value: &'a Record) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a Record> for Proven<&'a Record>

source§

fn from(record: &'a Record) -> Self

Converts to this type from the input type.
source§

impl<R: RecordData> From<Record<R>> for RecordParts<R>

source§

fn from(record: Record<R>) -> Self

Converts to this type from the input type.
source§

impl From<Record> for Proven<Record>

source§

fn from(record: Record) -> Self

Converts to this type from the input type.
source§

impl From<Record> for RecordSet

source§

fn from(record: Record) -> Self

Converts to this type from the input type.
source§

impl IntoRecordSet for Record

source§

fn into_record_set(self) -> RecordSet

👎Deprecated: use From/Into
Performs the conversion to a RecordSet
source§

impl Ord for Record

source§

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) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl<R: RecordData> PartialEq for Record<R>

source§

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
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Record

source§

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 · source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<R> Serialize for Record<R>
where R: Serialize + RecordData,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<'a, R: RecordData> TryFrom<&'a Record> for RecordRef<'a, R>

§

type Error = &'a Record

The type returned in the event of a conversion error.
source§

fn try_from(record: &'a Record) -> Result<Self, Self::Error>

Performs the conversion.
source§

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

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
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,