Trait domain::base::record::AsRecord

source ·
pub trait AsRecord {
    type Name: ToDname;
    type Data: RecordData;

    // Required methods
    fn owner(&self) -> &Self::Name;
    fn class(&self) -> Class;
    fn ttl(&self) -> u32;
    fn data(&self) -> &Self::Data;

    // Provided methods
    fn compose_record<T: OctetsBuilder + AsMut<[u8]>>(
        &self,
        target: &mut T
    ) -> Result<(), ShortBuf> { ... }
    fn compose_record_canonical<T: OctetsBuilder + AsMut<[u8]>>(
        &self,
        target: &mut T
    ) -> Result<(), ShortBuf> { ... }
}
Expand description

A helper trait allowing construction of records on the fly.

The trait’s primary users arer the three record section buider type of the [message builder] system. Their push methods accept anything that implements this trait.

Implementations are provided for Record values and references. In addition, a tuple of a domain name, class, TTL, and record data can be used as this trait, saving the detour of constructing a record first. Since the class is pretty much always Class::In, it can be left out in this case.

Required Associated Types§

source

type Name: ToDname

The type of the record’s owner domain name.

source

type Data: RecordData

The type of the record data.

Required Methods§

source

fn owner(&self) -> &Self::Name

Returns a reference to the owner domain name.

source

fn class(&self) -> Class

Returns the record’s class.

source

fn ttl(&self) -> u32

Returns the record’s TTL:

source

fn data(&self) -> &Self::Data

Returns a reference to the record data.

Provided Methods§

source

fn compose_record<T: OctetsBuilder + AsMut<[u8]>>( &self, target: &mut T ) -> Result<(), ShortBuf>

Produces the encoded record.

source

fn compose_record_canonical<T: OctetsBuilder + AsMut<[u8]>>( &self, target: &mut T ) -> Result<(), ShortBuf>

Produces the canonically encoded record.

Implementations on Foreign Types§

source§

impl<Name: ToDname, Data: RecordData> AsRecord for (Name, u32, Data)

§

type Name = Name

§

type Data = Data

source§

fn owner(&self) -> &Self::Name

source§

fn class(&self) -> Class

source§

fn ttl(&self) -> u32

source§

fn data(&self) -> &Self::Data

source§

impl<Name: ToDname, Data: RecordData> AsRecord for (Name, Class, u32, Data)

§

type Name = Name

§

type Data = Data

source§

fn owner(&self) -> &Self::Name

source§

fn class(&self) -> Class

source§

fn ttl(&self) -> u32

source§

fn data(&self) -> &Self::Data

source§

impl<'a, T: AsRecord> AsRecord for &'a T

§

type Name = <T as AsRecord>::Name

§

type Data = <T as AsRecord>::Data

source§

fn owner(&self) -> &Self::Name

source§

fn class(&self) -> Class

source§

fn ttl(&self) -> u32

source§

fn data(&self) -> &Self::Data

Implementors§

source§

impl<Name: ToDname, Data: RecordData> AsRecord for Record<Name, Data>

§

type Name = Name

§

type Data = Data