Enum UncertainDname

Source
pub enum UncertainDname {
    Absolute(Dname),
    Relative(RelativeDname),
}
Expand description

A domain name that may be absolute or relative.

This type is helpful when reading a domain name from some source where it may end up being absolute or not.

Variants§

§

Absolute(Dname)

§

Relative(RelativeDname)

Implementations§

Source§

impl UncertainDname

Source

pub fn absolute(name: Dname) -> Self

Creates a new uncertain domain name from an absolute domain name.

Source

pub fn relative(name: RelativeDname) -> Self

Creates a new uncertain domain name from a relative domain name.

Source

pub fn root() -> Self

Creates a new uncertain domain name containing the root label only.

Source

pub fn empty() -> Self

Creates a new uncertain yet empty domain name.

Source

pub fn from_chars<C>(chars: C) -> Result<Self, FromStrError>
where C: IntoIterator<Item = char>,

Creates a domain name from a sequence of characters.

The sequence must result in a domain name in master format representation. That is, its labels should be separated by dots, actual dots, white space and backslashes should be escaped by a preceeding backslash, and any byte value that is not a printable ASCII character should be encoded by a backslash followed by its three digit decimal value.

If the last character is a dot, the name will be absolute, otherwise it will be relative.

If you have a string, you can also use the FromStr trait, which really does the same thing.

Source

pub fn is_absolute(&self) -> bool

Returns whether the name is absolute.

Source

pub fn is_relative(&self) -> bool

Returns whether the name is relative.

Source

pub fn as_absolute(&self) -> Option<&Dname>

Returns a reference to an absolute name, if this name is absolute.

Source

pub fn as_relative(&self) -> Option<&RelativeDname>

Returns a reference to a relative name, if the name is relative.

Source

pub fn try_into_absolute(self) -> Result<Dname, Self>

Converts the name into an absolute name if it is absolute.

Otherwise, returns itself as the error.

Source

pub fn try_into_relative(self) -> Result<RelativeDname, Self>

Converts the name into a relative name if it is relative.

Otherwise just returns itself as the error.

Source

pub fn into_absolute(self) -> Dname

Converts the name into an absolute name.

If the name is relative, appends the root label to it using RelativeDname::into_absolute.

Source

pub fn chain<S: ToDname>( self, suffix: S, ) -> Result<Chain<Self, S>, LongChainError>

Makes an uncertain name absolute by chaining on a suffix if needed.

The method converts the uncertain name into a chain that will be absolute. If the name is already absolute, the chain will be the name itself. If it is relative, if will be the concatenation of the name and suffix.

Source

pub fn as_slice(&self) -> &[u8]

Returns a byte slice with the raw content of the name.

Trait Implementations§

Source§

impl Clone for UncertainDname

Source§

fn clone(&self) -> UncertainDname

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

impl Compose for UncertainDname

Source§

fn compose_len(&self) -> usize

Returns the number of bytes this value will need without compression.
Source§

fn compose<B: BufMut>(&self, buf: &mut B)

Appends the uncompressed representation of this value to buf. Read more
Source§

impl Debug for UncertainDname

Source§

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

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

impl Display for UncertainDname

Source§

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

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

impl From<Dname> for UncertainDname

Source§

fn from(name: Dname) -> Self

Converts to this type from the input type.
Source§

impl From<RelativeDname> for UncertainDname

Source§

fn from(name: RelativeDname) -> Self

Converts to this type from the input type.
Source§

impl FromStr for UncertainDname

Source§

type Err = FromStrError

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

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

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

impl Hash for UncertainDname

Source§

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

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 PartialEq for UncertainDname

Source§

fn eq(&self, other: &UncertainDname) -> 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.
Source§

impl Scan for UncertainDname

Source§

fn scan<C: CharSource>(scanner: &mut Scanner<C>) -> Result<Self, ScanError>

Scans a value from a master file.
Source§

impl<'a> ToLabelIter<'a> for UncertainDname

Source§

type LabelIter = DnameIter<'a>

The type of the iterator over the labels. Read more
Source§

fn iter_labels(&'a self) -> Self::LabelIter

Returns an iterator over the labels.
Source§

fn starts_with<N: ToLabelIter<'a>>(&'a self, base: &'a N) -> bool

Determines whether base is a prefix of self.
Source§

fn ends_with<N: ToLabelIter<'a>>(&'a self, base: &'a N) -> bool

Determines whether base is a suffix of self.
Source§

impl Eq for UncertainDname

Source§

impl StructuralPartialEq for UncertainDname

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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