#[repr(transparent)]pub struct Ptr<N> {
pub name: N,
}unstable-new only.Expand description
A pointer to another domain name.
A Ptr record is used with special domain names for pointing to other
locations in the domain name space. It is conventionally used for reverse
lookups: for example, the Ptr record for <addr>.in-addr.arpa points
to the domain name using the IPv4 <addr> in an A record. The same
technique works with <addr>.ip6.arpa for IPv6 addresses.
Ptr is specified by RFC 1035, section 3.3.12.
§Wire format
The wire format of a Ptr record is simply the domain name of the name
server. This domain name may be compressed in DNS messages.
§Usage
Because Ptr 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).
In order to build a Ptr, it’s first important to choose a domain name
type. For short-term usage (where the Ptr is a local variable), it is
common to pick RevNameBuf. If the Ptr will be placed on the heap,
Box< will be more efficient.RevName>
The primary way to build a new Ptr is to construct each field manually.
To parse a Ptr from a DNS message, use ParseMessageBytes. In case
the input bytes don’t use name compression, ParseBytes can be used.
// Build a 'Ptr' manually:
let manual: Ptr<RevNameBuf> = Ptr {
name: "example.org.".parse().unwrap(),
};
// Its wire format serialization looks like:
let bytes = b"\x07example\x03org\x00";
// Parse a 'Ptr' from the wire format, without name decompression:
let from_wire: Ptr<RevNameBuf> = Ptr::parse_bytes(bytes).unwrap();
// See 'ParseMessageBytes' for parsing with name decompression.Since Ptr is a sized type, and it implements Copy and Clone,
it’s straightforward to handle and move around. However, this depends on
the domain name type. It can be changed using Ptr::map_name() and
Ptr::map_name_by_ref().
For debugging, Ptr can be formatted using fmt::Debug.
To serialize a Ptr in the wire format, use BuildInMessage (which
supports name compression). If name compression is not desired, use
BuildBytes.
Fields§
§name: NThe referenced domain name.
Implementations§
Trait Implementations§
Source§impl<N> BuildBytes for Ptr<N>where
N: BuildBytes,
impl<N> BuildBytes for Ptr<N>where
N: BuildBytes,
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<N: BuildInMessage> BuildInMessage for Ptr<N>
impl<N: BuildInMessage> BuildInMessage for Ptr<N>
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<N: CanonicalName> CanonicalRecordData for Ptr<N>
impl<N: CanonicalName> CanonicalRecordData for Ptr<N>
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<N: Copy> Copy for Ptr<N>
impl<N: Eq> Eq for Ptr<N>
Source§impl<'a, N> From<Ptr<N>> for RecordData<'a, N>
impl<'a, N> From<Ptr<N>> for RecordData<'a, N>
Source§impl<N: Ord> Ord for Ptr<N>
impl<N: Ord> Ord for Ptr<N>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<'bytes, N> ParseBytes<'bytes> for Ptr<N>where
N: ParseBytes<'bytes>,
impl<'bytes, N> ParseBytes<'bytes> for Ptr<N>where
N: ParseBytes<'bytes>,
Source§fn parse_bytes(bytes: &'bytes [u8]) -> Result<Self, ParseError>
fn parse_bytes(bytes: &'bytes [u8]) -> Result<Self, ParseError>
Source§impl<'a, N: ParseMessageBytes<'a>> ParseMessageBytes<'a> for Ptr<N>
impl<'a, N: ParseMessageBytes<'a>> ParseMessageBytes<'a> for Ptr<N>
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, N: ParseMessageBytes<'a>> ParseRecordData<'a> for Ptr<N>
impl<'a, N: ParseMessageBytes<'a>> ParseRecordData<'a> for Ptr<N>
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, N: ParseBytes<'a>> ParseRecordDataBytes<'a> for Ptr<N>
impl<'a, N: ParseBytes<'a>> ParseRecordDataBytes<'a> for Ptr<N>
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<N: PartialOrd> PartialOrd for Ptr<N>
impl<N: PartialOrd> PartialOrd for Ptr<N>
Source§impl<'bytes, N> SplitBytes<'bytes> for Ptr<N>where
N: SplitBytes<'bytes>,
impl<'bytes, N> SplitBytes<'bytes> for Ptr<N>where
N: SplitBytes<'bytes>,
Source§fn split_bytes(bytes: &'bytes [u8]) -> Result<(Self, &'bytes [u8]), ParseError>
fn split_bytes(bytes: &'bytes [u8]) -> Result<(Self, &'bytes [u8]), ParseError>
impl<N: PartialEq> StructuralPartialEq for Ptr<N>
Auto Trait Implementations§
impl<N> Freeze for Ptr<N>where
N: Freeze,
impl<N> RefUnwindSafe for Ptr<N>where
N: RefUnwindSafe,
impl<N> Send for Ptr<N>where
N: Send,
impl<N> Sync for Ptr<N>where
N: Sync,
impl<N> Unpin for Ptr<N>where
N: Unpin,
impl<N> UnsafeUnpin for Ptr<N>where
N: UnsafeUnpin,
impl<N> UnwindSafe for Ptr<N>where
N: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.