Struct domain::bits::record::Record
[−]
[src]
pub struct Record<N: DName, D: RecordData> { /* fields omitted */ }
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 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 since 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. 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.
Since records contain domain names, the Record
type is additionally
generic over a domain name type.
There is three ways to create a record value. First, you can make one
yourself using the [new()
] function. In 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.
Records can be place into DNS messages through the value chain starting
with [MessageBuilder
]. In order to make adding records easier, Record
implements the From
trait for two kinds of tuples: A four-tuple of
name, class, time-to-live value, and record data and a triple leaving
out the class and assuming it to Class::In
.
Methods
impl<N: DName, D: RecordData> Record<N, D>
[src]
pub fn new(name: N, class: Class, ttl: u32, data: D) -> Self
[src]
Creates a new record from its parts.
pub fn name(&self) -> &N
[src]
Returns a reference to the domain name.
The domain name, sometimes called the owner of the record, specifies the node in the DNS tree this record belongs to.
pub fn rtype(&self) -> Rtype
[src]
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) -> &D
[src]
Return a reference to the record data.
pub fn data_mut(&mut self) -> &mut D
[src]
Returns a mutable reference to the record data.
pub fn into_data(self) -> D
[src]
Trades the record for its record data.
impl<'a, D: ParsedRecordData<'a>> Record<ParsedDName<'a>, D>
[src]
pub fn parse(parser: &mut Parser<'a>) -> ParseResult<Option<Self>>
[src]
Parses a record from a parser.
This function is only available for records that use a parsed domain name and a record data type that, too, can be parsed.
impl<'a> Record<ParsedDName<'a>, GenericRecordData<'a>>
[src]
pub fn parse_generic(parser: &mut Parser<'a>) -> ParseResult<Self>
[src]
Parses a record with generic data from a parser.
impl<N: DName, D: RecordData> Record<N, D>
[src]
pub fn compose<C: AsMut<Composer>>(&self, composer: C) -> ComposeResult<()>
[src]
Appends the record’s wire-format representation to a composer.
Trait Implementations
impl<N: Clone + DName, D: Clone + RecordData> Clone for Record<N, D>
[src]
fn clone(&self) -> Record<N, D>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<N: Debug + DName, D: Debug + RecordData> Debug for Record<N, D>
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<N: DName, D: RecordData> From<(N, Class, u32, D)> for Record<N, D>
[src]
impl<N: DName, D: RecordData> From<(N, u32, D)> for Record<N, D>
[src]
impl<N, D> Display for Record<N, D> where
N: DName + Display,
D: RecordData + Display,
[src]
N: DName + Display,
D: RecordData + Display,