[][src]Struct address::domain::Domain

pub struct Domain { /* fields omitted */ }

Represents a domain name.

Methods

impl Domain[src]

pub fn get_localhost() -> Self[src]

Gets the localhost domain.

use address::domain::Domain;

assert_eq!(Domain::get_localhost().to_string(), "localhost");

impl Domain[src]

pub const MAX_LABEL_LENGTH: usize[src]

The maximum length of a domain label.

pub const MAX_DOMAIN_LENGTH: usize[src]

The maximum length of a domain name.

pub fn is_valid_label(label: &[u8]) -> bool[src]

Checks if the domain label is valid. This function is case insensitive.

use address::domain::Domain;

assert!(!Domain::is_valid_label("".as_bytes()));
assert!(Domain::is_valid_label("a".as_bytes()));
assert!(Domain::is_valid_label("A".as_bytes()));
assert!(Domain::is_valid_label("0".as_bytes()));
assert!(!Domain::is_valid_label("a-".as_bytes()));
assert!(!Domain::is_valid_label("-a".as_bytes()));
assert!(Domain::is_valid_label("a-b".as_bytes()));

pub fn is_valid_domain(name: &[u8]) -> bool[src]

Checks if the domain name is valid. This function is case-insensitive.

use address::domain::Domain;

assert!(!Domain::is_valid_domain("".as_bytes()));
assert!(Domain::is_valid_domain("a".as_bytes()));
assert!(!Domain::is_valid_domain("a.".as_bytes()));
assert!(!Domain::is_valid_domain(".a".as_bytes()));
assert!(Domain::is_valid_domain("a.b".as_bytes()));

impl Domain[src]

pub fn name(&self) -> &String[src]

Gets the name.

pub fn host(self) -> Host[src]

Gets the host.

Trait Implementations

impl Clone for Domain[src]

impl Eq for Domain[src]

impl Ord for Domain[src]

impl PartialEq<Domain> for Domain[src]

impl PartialOrd<Domain> for Domain[src]

impl Display for Domain[src]

fn fmt(&self, f: &mut Formatter) -> Result<(), Error>[src]

use address::domain::Domain;
use std::convert::TryFrom;

assert_eq!(Domain::try_from("a").ok().unwrap().to_string(), "a");

impl Debug for Domain[src]

impl<'_> TryFrom<&'_ [u8]> for Domain[src]

type Error = &'static str

The type returned in the event of a conversion error.

fn try_from(value: &[u8]) -> Result<Self, Self::Error>[src]

use address::domain::Domain;
use std::convert::TryFrom;

let e: Result<Domain, &'static str> = Err("Invalid Domain");
assert_eq!(Domain::try_from(""), e);
assert_eq!(Domain::try_from("a").ok().unwrap().to_string(), "a");
assert_eq!(Domain::try_from("a."), e);
assert_eq!(Domain::try_from(".a"), e);
assert_eq!(Domain::try_from("a.b").ok().unwrap().to_string(), "a.b");

impl<'_> TryFrom<&'_ str> for Domain[src]

type Error = &'static str

The type returned in the event of a conversion error.

impl Hash for Domain[src]

Auto Trait Implementations

impl Send for Domain

impl Sync for Domain

impl Unpin for Domain

impl UnwindSafe for Domain

impl RefUnwindSafe for Domain

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]