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§
sourcetype Data: RecordData
type Data: RecordData
The type of the record data.
Required Methods§
Provided Methods§
sourcefn compose_record<T: OctetsBuilder + AsMut<[u8]>>(
&self,
target: &mut T
) -> Result<(), ShortBuf>
fn compose_record<T: OctetsBuilder + AsMut<[u8]>>( &self, target: &mut T ) -> Result<(), ShortBuf>
Produces the encoded record.
sourcefn compose_record_canonical<T: OctetsBuilder + AsMut<[u8]>>(
&self,
target: &mut T
) -> Result<(), ShortBuf>
fn compose_record_canonical<T: OctetsBuilder + AsMut<[u8]>>( &self, target: &mut T ) -> Result<(), ShortBuf>
Produces the canonically encoded record.