#[repr(transparent)]pub struct DName {
pub name: Name,
}unstable-new only.Expand description
Redirection for the descendants of this domain.
A DName record indicates that a doamin name is a (partial!) alias.
Queries for data under that domain name (not that domain name itself)
are redirected to the specified target. A domain name can have at most one
DName record; in this case, it cannot define subordinate records nor
have a CName record. It is conceptually similar to CName.
DName is specified by RFC 6672.
§Wire Format
The wire format of a DName record is simply the target domain name.
This domain name cannot be compressed in DNS messages.
The memory layout of the DName type is identical to its serialization
in the wire format. This means that it can be parsed from the wire format
in a zero-copy fashion, which is more efficient.
§Usage
Because DName is a record data type, it is usually handled within
an enum like RecordData. This section describes how to use it
independently (or when building new record data from scratch).
DName is a dynamically sized type (DST). It is not possible to
store an DName in place (e.g. in a local variable); it must be held
indirectly, via a reference or a smart pointer type like Box. This
makes it more difficult to create new DNames; but once they are
placed somewhere, they can be used by reference (i.e. &DName) exactly
like any other type.
It is currently a bit difficult to build a new DName from scratch.
It is easiest to use DName::new() on a reference to a Name, or to
build the wire format representation of the DName manually and then to
parse it.
// Parse a 'Name' and build a 'DName' from there:
let name = "example.org.".parse::<NameBuf>().unwrap();
let dname = DName::new(&name);
// Parse a 'DName' from the DNS wire format:
let bytes = b"\x07example\x03org\x00";
let from_bytes: &DName = <&DName>::parse_bytes(bytes).unwrap();
assert_eq!(dname.as_bytes(), bytes);
// Copy a 'DName' onto the heap:
let heaped: Box<DName> = dname.unsized_copy_into();As a DST, DName does not implement Copy or Clone. Instead, it
implements UnsizedCopy. A DName, held by reference, can be copied
into a different container (e.g. Box) using unsized_copy_into()
For debugging, DName can be formatted using fmt::Debug.
To serialize a DName in the wire format, use BuildBytes
(which will serialize it to a given buffer) or AsBytes (which will
cast the DName into a byte sequence in place). It also supports
BuildInMessage.
Fields§
§name: NameThe target name.
Implementations§
Trait Implementations§
Source§impl BuildBytes for DName
impl BuildBytes for DName
Source§fn build_bytes<'bytes>(
&self,
bytes: &'bytes mut [u8],
) -> Result<&'bytes mut [u8], TruncationError>
fn build_bytes<'bytes>( &self, bytes: &'bytes mut [u8], ) -> Result<&'bytes mut [u8], TruncationError>
Source§fn built_bytes_size(&self) -> usize
fn built_bytes_size(&self) -> usize
self when serialized into a byte sequence. Read moreSource§impl BuildInMessage for DName
impl BuildInMessage for DName
Source§fn build_in_message(
&self,
contents: &mut [u8],
start: usize,
compressor: &mut NameCompressor,
) -> Result<usize, TruncationError>
fn build_in_message( &self, contents: &mut [u8], start: usize, compressor: &mut NameCompressor, ) -> Result<usize, TruncationError>
Source§impl CanonicalRecordData for DName
impl CanonicalRecordData for DName
Source§fn build_canonical_bytes<'b>(
&self,
bytes: &'b mut [u8],
) -> Result<&'b mut [u8], TruncationError>
fn build_canonical_bytes<'b>( &self, bytes: &'b mut [u8], ) -> Result<&'b mut [u8], TruncationError>
Source§fn cmp_canonical(&self, other: &Self) -> Ordering
fn cmp_canonical(&self, other: &Self) -> Ordering
impl Eq for DName
Source§impl<'a, N> From<&'a DName> for RecordData<'a, N>
impl<'a, N> From<&'a DName> for RecordData<'a, N>
Source§impl ParseBytesZC for DName
impl ParseBytesZC for DName
Source§fn parse_bytes_by_ref(bytes: &[u8]) -> Result<&Self, ParseError>
fn parse_bytes_by_ref(bytes: &[u8]) -> Result<&Self, ParseError>
Source§fn parse_bytes_in<C: ParseBytesInPlace>(
container: C,
) -> Result<C::WithParsed<Self>, (C, ParseError)>
fn parse_bytes_in<C: ParseBytesInPlace>( container: C, ) -> Result<C::WithParsed<Self>, (C, ParseError)>
Source§impl<'a> ParseMessageBytes<'a> for &'a DName
impl<'a> ParseMessageBytes<'a> for &'a DName
Source§fn parse_message_bytes(
contents: &'a [u8],
start: usize,
) -> Result<Self, ParseError>
fn parse_message_bytes( contents: &'a [u8], start: usize, ) -> Result<Self, ParseError>
Source§impl<'a> ParseRecordData<'a> for &'a DName
impl<'a> ParseRecordData<'a> for &'a DName
Source§fn parse_record_data(
contents: &'a [u8],
start: usize,
rtype: RType,
) -> Result<Self, ParseError>
fn parse_record_data( contents: &'a [u8], start: usize, rtype: RType, ) -> Result<Self, ParseError>
Source§impl<'a> ParseRecordDataBytes<'a> for &'a DName
impl<'a> ParseRecordDataBytes<'a> for &'a DName
Source§fn parse_record_data_bytes(
bytes: &'a [u8],
rtype: RType,
) -> Result<Self, ParseError>
fn parse_record_data_bytes( bytes: &'a [u8], rtype: RType, ) -> Result<Self, ParseError>
Source§impl PartialOrd for DName
impl PartialOrd for DName
Source§impl SplitBytesZC for DName
impl SplitBytesZC for DName
Source§fn split_bytes_by_ref(bytes: &[u8]) -> Result<(&Self, &[u8]), ParseError>
fn split_bytes_by_ref(bytes: &[u8]) -> Result<(&Self, &[u8]), ParseError>
impl StructuralPartialEq for DName
Source§impl UnsizedCopy for DName
impl UnsizedCopy for DName
Source§type Alignment = (<Name as UnsizedCopy>::Alignment,)
type Alignment = (<Name as UnsizedCopy>::Alignment,)
Self. Read moreSource§fn ptr_with_addr(&self, addr: *const ()) -> *const Self
fn ptr_with_addr(&self, addr: *const ()) -> *const Self
Self. Read moreSource§fn unsized_copy_into<T: UnsizedCopyFrom<Source = Self>>(&self) -> T
fn unsized_copy_into<T: UnsizedCopyFrom<Source = Self>>(&self) -> T
self into a new container. Read more