[−][src]Struct domain::base::record::Record
A DNS resource record.
All information available through the DNS is stored in resource records. They have a three part key of a domain name, resource record type, and class. Data is arranged in a tree which is navigated using the domain name. Each node in the tree carries a label, starting with the root label as the top-most node. The tree is traversed by stepping through the name from right to left, finding a child node carring the label of each step. The domain name resulting from this traversal is part of the record itself. It is called the owner of the record.
The record type describes the kind of data the record holds, such as IP addresses. The class, finally, describes which sort of network the information is for. The DNS was originally intended to be used for networks other than the Internet as well. In practice, the only relevant class is IN, the Internet. Note that each class has its own tree of nodes.
The payload of a resource record is its data. Its purpose, meaning, and format is determined by the record type (technically, also its class). For each unique three-part key there can be multiple resource records. All these records for the same key are called resource record sets, most often shortened to ‘RRset.’
There is one more piece of data: the TTL or time to live. This value says how long a record remains valid before it should be refreshed from its original source, given in seconds. The TTL is used to add caching facilities to the DNS.
Values of the Record
type represent one single resource record. Since
there are currently more than eighty record types—see Rtype
for a
complete list—, the type is generic over a trait for record data. This
trait holds both the record type value and the record data as they are
inseparably entwined.
Because a record’s owner is a domain name, the Record
type is
additionally generic over the domain name type is for it.
There is three ways to create a record value. First, you can make one
yourself using the new
function. It will neatly take care of all
the generics through type inference. Secondly, you can parse a record
from an existing message. Message
and its friends provide a way to
do that; see there for all the details. Finally, you can scan a record
from master data (aka zonefiles). See the domain::master
module for
that.
Implementations
impl<Name, Data> Record<Name, Data>
[src]
pub fn new(owner: Name, class: Class, ttl: u32, data: Data) -> Self
[src]
Creates a new record from its parts.
pub fn from_record<NN, DD>(record: Record<NN, DD>) -> Self where
Name: From<NN>,
Data: From<DD>,
[src]
Name: From<NN>,
Data: From<DD>,
Creates a new record from a compatible record.
This function only exists because the equivalent From
implementation
is currently not possible,
pub fn owner(&self) -> &Name
[src]
Returns a reference to the owner domain name.
The owner of a record is the domain name that specifies the node in the DNS tree this record belongs to.
pub fn rtype(&self) -> Rtype where
Data: RecordData,
[src]
Data: RecordData,
Returns the record type.
pub fn class(&self) -> Class
[src]
Returns the record class.
pub fn set_class(&mut self, class: Class)
[src]
Sets the record’s class.
pub fn ttl(&self) -> u32
[src]
Returns the record’s time-to-live.
pub fn set_ttl(&mut self, ttl: u32)
[src]
Sets the record’s time-to-live.
pub fn data(&self) -> &Data
[src]
Return a reference to the record data.
pub fn data_mut(&mut self) -> &mut Data
[src]
Returns a mutable reference to the record data.
pub fn into_data(self) -> Data
[src]
Trades the record for its record data.
Trait Implementations
impl<Name: ToDname, Data: RecordData> AsRecord for Record<Name, Data>
[src]
type Name = Name
The type of the record’s owner domain name.
type Data = Data
The type of the record data.
fn owner(&self) -> &Self::Name
[src]
fn class(&self) -> Class
[src]
fn ttl(&self) -> u32
[src]
fn data(&self) -> &Self::Data
[src]
fn compose_record<T: OctetsBuilder>(
&self,
target: &mut T
) -> Result<(), ShortBuf>
[src]
&self,
target: &mut T
) -> Result<(), ShortBuf>
fn compose_record_canonical<T: OctetsBuilder>(
&self,
target: &mut T
) -> Result<(), ShortBuf>
[src]
&self,
target: &mut T
) -> Result<(), ShortBuf>
impl<N, NN, D, DD> CanonicalOrd<Record<NN, DD>> for Record<N, D> where
N: ToDname,
NN: ToDname,
D: RecordData + CanonicalOrd<DD>,
DD: RecordData,
[src]
N: ToDname,
NN: ToDname,
D: RecordData + CanonicalOrd<DD>,
DD: RecordData,
fn canonical_cmp(&self, other: &Record<NN, DD>) -> Ordering
[src]
#[must_use]fn canonical_lt(&self, other: &Rhs) -> bool
[src]
#[must_use]fn canonical_le(&self, other: &Rhs) -> bool
[src]
#[must_use]fn canonical_gt(&self, other: &Rhs) -> bool
[src]
#[must_use]fn canonical_ge(&self, other: &Rhs) -> bool
[src]
impl<Name: Clone, Data: Clone> Clone for Record<Name, Data>
[src]
impl<N: ToDname, D: RecordData> Compose for Record<N, D>
[src]
fn compose<T: OctetsBuilder>(&self, target: &mut T) -> Result<(), ShortBuf>
[src]
fn compose_canonical<T: OctetsBuilder>(
&self,
target: &mut T
) -> Result<(), ShortBuf>
[src]
&self,
target: &mut T
) -> Result<(), ShortBuf>
impl<Name, Data> Debug for Record<Name, Data> where
Name: Debug,
Data: Debug,
[src]
Name: Debug,
Data: Debug,
impl<Name, Data> Display for Record<Name, Data> where
Name: Display,
Data: RecordData + Display,
[src]
Name: Display,
Data: RecordData + Display,
impl<N: Eq, D: RecordData + Eq> Eq for Record<N, D>
[src]
impl<N, D> From<(N, Class, u32, D)> for Record<N, D>
[src]
impl<N, D> From<(N, u32, D)> for Record<N, D>
[src]
impl<Octets, N: ToDname> From<Record<N, Opt<Octets>>> for OptRecord<Octets>
[src]
impl<Name, Data> Hash for Record<Name, Data> where
Name: Hash,
Data: Hash,
[src]
Name: Hash,
Data: Hash,
fn hash<H: Hasher>(&self, state: &mut H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<N, D> Ord for Record<N, D> where
N: Ord,
D: RecordData + Ord,
[src]
N: Ord,
D: RecordData + Ord,
fn cmp(&self, other: &Self) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<N, NN, D, DD> PartialEq<Record<NN, DD>> for Record<N, D> where
N: PartialEq<NN>,
D: RecordData + PartialEq<DD>,
DD: RecordData,
[src]
N: PartialEq<NN>,
D: RecordData + PartialEq<DD>,
DD: RecordData,
fn eq(&self, other: &Record<NN, DD>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<N, NN, D, DD> PartialOrd<Record<NN, DD>> for Record<N, D> where
N: PartialOrd<NN>,
D: RecordData + PartialOrd<DD>,
DD: RecordData,
[src]
N: PartialOrd<NN>,
D: RecordData + PartialOrd<DD>,
DD: RecordData,
Auto Trait Implementations
impl<Name, Data> RefUnwindSafe for Record<Name, Data> where
Data: RefUnwindSafe,
Name: RefUnwindSafe,
Data: RefUnwindSafe,
Name: RefUnwindSafe,
impl<Name, Data> Send for Record<Name, Data> where
Data: Send,
Name: Send,
Data: Send,
Name: Send,
impl<Name, Data> Sync for Record<Name, Data> where
Data: Sync,
Name: Sync,
Data: Sync,
Name: Sync,
impl<Name, Data> Unpin for Record<Name, Data> where
Data: Unpin,
Name: Unpin,
Data: Unpin,
Name: Unpin,
impl<Name, Data> UnwindSafe for Record<Name, Data> where
Data: UnwindSafe,
Name: UnwindSafe,
Data: UnwindSafe,
Name: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,