Struct ANAME

pub struct ANAME(pub Name);
Expand description

new type for the RecordData of ANAME

Tuple Fields§

§0: Name

Methods from Deref<Target = Name>§

pub const MAX_LENGTH: usize = 255usize

pub fn is_root(&self) -> bool

Returns true if there are no labels, i.e. it’s empty.

In DNS the root is represented by .

§Examples
use hickory_proto::rr::domain::Name;

let root = Name::root();
assert_eq!(&root.to_string(), ".");

pub fn is_fqdn(&self) -> bool

Returns true if the name is a fully qualified domain name.

If this is true, it has effects like only querying for this single name, as opposed to building up a search list in resolvers.

warning: this interface is unstable and may change in the future

§Examples
use std::str::FromStr;
use hickory_proto::rr::domain::Name;

let name = Name::from_str("www").unwrap();
assert!(!name.is_fqdn());

let name = Name::from_str("www.example.com").unwrap();
assert!(!name.is_fqdn());

let name = Name::from_str("www.example.com.").unwrap();
assert!(name.is_fqdn());

pub fn iter(&self) -> LabelIter<'_>

Returns an iterator over the labels

pub fn prepend_label<L>(&self, label: L) -> Result<Name, ProtoError>
where L: IntoLabel,

Prepends the label to the beginning of this name

§Example
use std::str::FromStr;
use hickory_proto::rr::domain::Name;

let name = Name::from_str("example.com").unwrap();
let name = name.prepend_label("www").unwrap();
assert_eq!(name, Name::from_str("www.example.com").unwrap());

pub fn to_lowercase(&self) -> Name

Creates a new Name with all labels lowercased

§Examples
use std::cmp::Ordering;
use std::str::FromStr;

use hickory_proto::rr::domain::{Label, Name};

let example_com = Name::from_ascii("Example.Com").unwrap();
assert_eq!(example_com.cmp_case(&Name::from_str("example.com").unwrap()), Ordering::Less);
assert!(example_com.to_lowercase().eq_case(&Name::from_str("example.com").unwrap()));

pub fn base_name(&self) -> Name

Trims off the first part of the name, to help with searching for the domain piece

§Examples
use std::str::FromStr;
use hickory_proto::rr::domain::Name;

let example_com = Name::from_str("example.com.").unwrap();
assert_eq!(example_com.base_name(), Name::from_str("com.").unwrap());
assert_eq!(Name::from_str("com.").unwrap().base_name(), Name::root());
assert_eq!(Name::root().base_name(), Name::root());

pub fn trim_to(&self, num_labels: usize) -> Name

Trims to the number of labels specified

§Examples
use std::str::FromStr;
use hickory_proto::rr::domain::Name;

let example_com = Name::from_str("example.com.").unwrap();
assert_eq!(example_com.trim_to(2), Name::from_str("example.com.").unwrap());
assert_eq!(example_com.trim_to(1), Name::from_str("com.").unwrap());
assert_eq!(example_com.trim_to(0), Name::root());
assert_eq!(example_com.trim_to(3), Name::from_str("example.com.").unwrap());

pub fn zone_of_case(&self, name: &Name) -> bool

same as zone_of allows for case sensitive call

pub fn zone_of(&self, name: &Name) -> bool

returns true if the name components of self are all present at the end of name

§Example
use std::str::FromStr;
use hickory_proto::rr::domain::Name;

let name = Name::from_str("www.example.com").unwrap();
let zone = Name::from_str("example.com").unwrap();
let another = Name::from_str("example.net").unwrap();
assert!(zone.zone_of(&name));
assert!(!name.zone_of(&zone));
assert!(!another.zone_of(&name));

pub fn num_labels(&self) -> u8

Returns the number of labels in the name, discounting *.

§Examples
use std::str::FromStr;
use hickory_proto::rr::domain::Name;

let root = Name::root();
assert_eq!(root.num_labels(), 0);

let example_com = Name::from_str("example.com").unwrap();
assert_eq!(example_com.num_labels(), 2);

let star_example_com = Name::from_str("*.example.com.").unwrap();
assert_eq!(star_example_com.num_labels(), 2);

pub fn len(&self) -> usize

returns the length in bytes of the labels. ‘.’ counts as 1

This can be used as an estimate, when serializing labels, though escaping may cause the exact length to be different.

§Examples
use std::str::FromStr;
use hickory_proto::rr::domain::Name;

assert_eq!(Name::from_str("www.example.com.").unwrap().len(), 16);
assert_eq!(Name::from_str(".").unwrap().len(), 1);
assert_eq!(Name::root().len(), 1);

pub fn is_empty(&self) -> bool

Returns whether the length of the labels, in bytes is 0. In practice, since ‘.’ counts as 1, this is never the case so the method returns false.

pub fn emit_as_canonical( &self, encoder: &mut BinEncoder<'_>, canonical: bool, ) -> Result<(), ProtoError>

Emits the canonical version of the name to the encoder.

In canonical form, there will be no pointers written to the encoder (i.e. no compression).

pub fn emit_with_lowercase( &self, encoder: &mut BinEncoder<'_>, lowercase: bool, ) -> Result<(), ProtoError>

Writes the labels, as lower case, to the encoder

§Arguments
  • encoder - encoder for writing this name
  • lowercase - if true the name will be lowercased, otherwise it will not be changed when writing

pub fn cmp_case(&self, other: &Name) -> Ordering

Case sensitive comparison

pub fn eq_case(&self, other: &Name) -> bool

Compares the Names, in a case sensitive manner

pub fn eq_ignore_root(&self, other: &Name) -> bool

Non-FQDN-aware case-insensitive comparison

This will return true if names are equal, or if an otherwise equal relative and non-relative name are compared.

§Examples
use std::str::FromStr;
use hickory_proto::rr::domain::Name;

let name1 = Name::from_str("a.com.").unwrap();
let name2 = name1.clone();
assert_eq!(&name1, &name2);
assert!(name1.eq_ignore_root(&name2));

// Make name2 uppercase.
let name2 = Name::from_str("A.CoM.").unwrap();
assert_eq!(&name1, &name2);
assert!(name1.eq_ignore_root(&name2));

// Make name2 a relative name.
// Note that standard equality testing now returns false.
let name2 = Name::from_str("a.com").unwrap();
assert!(&name1 != &name2);
assert!(name1.eq_ignore_root(&name2));

// Make name2 a completely unrelated name.
let name2 = Name::from_str("b.com.").unwrap();
assert!(&name1 != &name2);
assert!(!name1.eq_ignore_root(&name2));

pub fn eq_ignore_root_case(&self, other: &Name) -> bool

Non-FQDN-aware case-sensitive comparison

This will return true if names are equal, or if an otherwise equal relative and non-relative name are compared.

§Examples
use std::str::FromStr;
use hickory_proto::rr::domain::Name;

let name1 = Name::from_str("a.com.").unwrap();
let name2 = Name::from_ascii("A.CoM.").unwrap();
let name3 = Name::from_ascii("A.CoM").unwrap();

assert_eq!(&name1, &name2);
assert!(name1.eq_ignore_root(&name2));
assert!(!name1.eq_ignore_root_case(&name2));
assert!(name2.eq_ignore_root_case(&name3));

pub fn to_ascii(&self) -> String

Converts this name into an ascii safe string.

If the name is an IDNA name, then the name labels will be returned with the xn-- prefix. see to_utf8 or the Display impl for methods which convert labels to utf8.

pub fn to_utf8(&self) -> String

Converts the Name labels to the utf8 String form.

This converts the name to an unescaped format, that could be used with parse. If, the name is is followed by the final ., e.g. as in www.example.com., which represents a fully qualified Name.

pub fn parse_arpa_name(&self) -> Result<IpNet, ProtoError>

Converts a *.arpa Name in a PTR record back into an IpNet if possible.

pub fn is_localhost(&self) -> bool

Returns true if the Name is either localhost or in the localhost zone.

§Example
use std::str::FromStr;
use hickory_proto::rr::Name;

let name = Name::from_str("localhost").unwrap();
assert!(name.is_localhost());

let name = Name::from_str("localhost.").unwrap();
assert!(name.is_localhost());

let name = Name::from_str("my.localhost.").unwrap();
assert!(name.is_localhost());

pub fn is_wildcard(&self) -> bool

True if the first label of this name is the wildcard, i.e. ‘*’

§Example
use std::str::FromStr;
use hickory_proto::rr::Name;

let name = Name::from_str("www.example.com").unwrap();
assert!(!name.is_wildcard());

let name = Name::from_str("*.example.com").unwrap();
assert!(name.is_wildcard());

let name = Name::root();
assert!(!name.is_wildcard());

Trait Implementations§

§

impl<'r> BinDecodable<'r> for ANAME

§

fn read(decoder: &mut BinDecoder<'r>) -> Result<ANAME, ProtoError>

Read the type from the stream
§

fn from_bytes(bytes: &'r [u8]) -> Result<Self, ProtoError>

Returns the object in binary form
§

impl BinEncodable for ANAME

§

fn emit(&self, encoder: &mut BinEncoder<'_>) -> Result<(), ProtoError>

Write the type to the stream
§

fn to_bytes(&self) -> Result<Vec<u8>, ProtoError>

Returns the object in binary form
§

impl Clone for ANAME

§

fn clone(&self) -> ANAME

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for ANAME

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl Deref for ANAME

§

type Target = Name

The resulting type after dereferencing.
§

fn deref(&self) -> &<ANAME as Deref>::Target

Dereferences the value.
§

impl Display for ANAME

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl Hash for ANAME

§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
§

impl PartialEq for ANAME

§

fn eq(&self, other: &ANAME) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl RecordData for ANAME

§

fn try_from_rdata(data: RData) -> Result<ANAME, RData>

Attempts to convert to this RecordData from the RData type, if it is not the correct type the original is returned
§

fn try_borrow(data: &RData) -> Option<&ANAME>

Attempts to borrow this RecordData from the RData type, if it is not the correct type the original is returned
§

fn record_type(&self) -> RecordType

Get the associated RecordType for the RecordData
§

fn into_rdata(self) -> RData

Converts this RecordData into generic RecordData
§

fn is_update(&self) -> bool

RDLENGTH = 0
§

impl Eq for ANAME

§

impl StructuralPartialEq for ANAME

Auto Trait Implementations§

§

impl Freeze for ANAME

§

impl RefUnwindSafe for ANAME

§

impl Send for ANAME

§

impl Sync for ANAME

§

impl Unpin for ANAME

§

impl UnwindSafe for ANAME

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
§

impl<T, U> RamaFrom<T> for U
where U: From<T>,

§

fn rama_from(value: T) -> U

§

impl<T, U, CrateMarker> RamaInto<U, CrateMarker> for T
where U: RamaFrom<T, CrateMarker>,

§

fn rama_into(self) -> U

§

impl<T, U> RamaTryFrom<T> for U
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

§

fn rama_try_from(value: T) -> Result<U, <U as RamaTryFrom<T>>::Error>

§

impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for T
where U: RamaTryFrom<T, CrateMarker>,

§

type Error = <U as RamaTryFrom<T, CrateMarker>>::Error

§

fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T, CrateMarker>>::Error>

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T> ToSmolStr for T
where T: Display + ?Sized,

§

fn to_smolstr(&self) -> SmolStr

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
§

impl<T> ToStringFallible for T
where T: Display,

§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,