Struct trust_dns::rr::domain::Name [] [src]

pub struct Name { /* fields omitted */ }

TODO: all Names 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 TODO: Currently this probably doesn't support binary names, it would be nice to do that.

Methods

impl Name
[src]

inline builder

for mutating over time

prepend the String to the label

appends the String to this label at the end

appends the other to this name

Creates a new Name with all labels lowercased

use trust_dns::rr::domain::Name;
use std::cmp::Ordering;

let example_com = Name::new().label("Example").label("Com");
assert_eq!(example_com.to_lowercase().cmp_with_case(&Name::new().label("example").label("com"), false), Ordering::Equal);

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

use trust_dns::rr::domain::Name;

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

Trims to the number of labels specified

use trust_dns::rr::domain::Name;

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

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

returns the length in bytes of the labels. '.' counts as 1

attempts to parse a name such as "example.com." or "subdomain.example.com."

Examples

use trust_dns::rr::domain::Name;

let name = Name::parse("example.com.", None).unwrap();
assert_eq!(name.base_name(), Name::new().label("com"));
assert_eq!(*name[0], String::from("example"));

compares with the other label, ignoring case

Trait Implementations

impl Debug for Name
[src]

Formats the value using the given formatter.

impl Eq for Name
[src]

impl Clone for Name
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Hash for Name
[src]

Feeds this value into the state given, updating the hasher as necessary.

Feeds a slice of this type into the state provided.

impl PartialEq<Name> for Name
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl BinSerializable<Name> for Name
[src]

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

impl Display for Name
[src]

Formats the value using the given formatter.

impl Index<usize> for Name
[src]

The returned type after indexing

The method for the indexing (container[index]) operation

impl PartialOrd<Name> for Name
[src]

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

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

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

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

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

impl Ord for Name
[src]

RFC 4034 DNSSEC Resource Records March 2005

6.1.  Canonical DNS Name 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