Struct hickory_proto::rr::LowerName

source ·
pub struct LowerName(/* private fields */);
Expand description

TODO: all LowerNames should be stored in a global “intern” space, and then everything that uses them should be through references. As a workaround the Strings are all Rc as well as the array

Implementations§

source§

impl LowerName

source

pub fn new(name: &Name) -> Self

Create a new domain::LowerName, i.e. label

source

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::{LowerName, Name};

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

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::{LowerName, Name};

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

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

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

pub fn base_name(&self) -> Self

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::{LowerName, Name};

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

pub fn zone_of(&self, name: &Self) -> 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::{LowerName, Name};

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

pub fn num_labels(&self) -> u8

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

§Examples
use std::str::FromStr;
use hickory_proto::rr::{LowerName, Name};

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

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

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

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, they will often be compressed and/or escaped causing the exact length to be different.

source

pub fn is_empty(&self) -> bool

Returns true if the name is empty

source

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

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).

source

pub fn is_wildcard(&self) -> bool

Pass through for Name::is_wildcard

source

pub fn into_wildcard(self) -> Self

Replaces the first label with the wildcard character, “*”

Trait Implementations§

source§

impl<'r> BinDecodable<'r> for LowerName

source§

fn read(decoder: &mut BinDecoder<'r>) -> ProtoResult<Self>

parses the chain of labels this has a max of 255 octets, with each label being less than 63. all names will be stored lowercase internally. This will consume the portions of the Vec which it is reading…

source§

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

Returns the object in binary form
source§

impl BinEncodable for LowerName

source§

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

Write the type to the stream
source§

fn to_bytes(&self) -> ProtoResult<Vec<u8>>

Returns the object in binary form
source§

impl Borrow<Name> for LowerName

source§

fn borrow(&self) -> &Name

Immutably borrows from an owned value. Read more
source§

impl Clone for LowerName

source§

fn clone(&self) -> LowerName

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for LowerName

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for LowerName

source§

fn default() -> LowerName

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for LowerName

source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for LowerName

source§

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

Formats the value using the given formatter. Read more
source§

impl<'a> From<&'a LowerName> for Name

source§

fn from(name: &'a LowerName) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a Name> for LowerName

source§

fn from(name: &'a Name) -> Self

Converts to this type from the input type.
source§

impl From<LowerName> for Name

source§

fn from(name: LowerName) -> Self

Converts to this type from the input type.
source§

impl From<Name> for LowerName

source§

fn from(name: Name) -> Self

Converts to this type from the input type.
source§

impl FromStr for LowerName

§

type Err = ProtoError

The associated error which can be returned from parsing.
source§

fn from_str(name: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl Hash for LowerName

source§

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
source§

impl Ord for LowerName

source§

fn cmp(&self, other: &Self) -> Ordering

Given two lower cased names, this performs a case sensitive comparison.

RFC 4034                DNSSEC Resource Records               March 2005

6.1.  Canonical DNS LowerName Order

 For the purposes of DNS security, owner names are ordered by treating
 individual labels as unsigned left-justified octet strings.  The
 absence of a octet sorts before a zero value octet, and uppercase
 US-ASCII letters are treated as if they were lowercase US-ASCII
 letters.

 To compute the canonical ordering of a set of DNS names, start by
 sorting the names according to their most significant (rightmost)
 labels.  For names in which the most significant label is identical,
 continue sorting according to their next most significant label, and
 so forth.

 For example, the following names are sorted in canonical DNS name
 order.  The most significant label is "example".  At this level,
 "example" sorts first, followed by names ending in "a.example", then
 by names ending "z.example".  The names within each level are sorted
 in the same way.

           example
           a.example
           yljkjljk.a.example
           Z.a.example
           zABC.a.EXAMPLE
           z.example
           \001.z.example
           *.z.example
           \200.z.example
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for LowerName

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

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

impl PartialOrd for LowerName

source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Serialize for LowerName

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for LowerName

Auto Trait Implementations§

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
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<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
source§

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

source§

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

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

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

source§

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

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

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

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

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

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> IntoName for T
where T: Into<Name>,

source§

fn into_name(self) -> Result<Name, ProtoError>

Convert this into Name
source§

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

§

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
source§

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

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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>,

§

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.
source§

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

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

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
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,