Enum hostsmod::HostsPart[][src]

pub enum HostsPart<'a> {
    Entry(IpAddrVec<Cow<'a, str>>, Option<Cow<'a, str>>),
    CommentedEntry(IpAddrVec<Cow<'a, str>>, Option<Cow<'a, str>>),
    Comment(Cow<'a, str>),
    Empty(Cow<'a, str>),
}

Part of a hosts file, representing all of the possible values.

Variants

Entry(IpAddrVec<Cow<'a, str>>, Option<Cow<'a, str>>)

An entry as outlined in man 5 hosts. Starting with an IP address (v4 or v6), followed by at least one space or tab, then a hostname, alphanumeric+.+-. Optional host aliases may be present, set apart by at least one more space or tab each.

A # character at any point will start a comment until the next line break.

CommentedEntry(IpAddrVec<Cow<'a, str>>, Option<Cow<'a, str>>)

An entry matching the Entry pattern, only commented out by a # character at the beginning of the line. This differentiation might be used to only disable entries while leaving the information still present in the file (eg. for human consumption).

Comment(Cow<'a, str>)

A comment, consisting of a # character followed by arbitrary text until the next line break..

Empty(Cow<'a, str>)

An empty part of a hosts file will contain only whitespace (or an empty string for a single line break).

Implementations

impl<'a> HostsPart<'a>[src]

pub fn matches_ip(&self, ip_needle: &IpAddr) -> bool[src]

Checks whether a hosts file part matches the provided IP address. Considers commented-out entries.

pub fn matches_hostname(&self, host_needle: &str) -> bool[src]

Checks whether a hosts file part contains the provided hostname. Aliases are considered, as are commented-out entries.

pub fn is_empty(&self) -> bool[src]

Checks whether a hosts file part is empty.

pub fn is_commented(&self) -> bool[src]

Checks whether a hosts file part is a commented-out entry.

pub fn get_family(&self) -> Option<HostsPartFamily>[src]

If a hosts file part contains an IP address, returns that addresses family (v4 or v6). Considers commented-out entries.

Trait Implementations

impl<'a> Clone for HostsPart<'a>[src]

impl<'a> Debug for HostsPart<'a>[src]

impl<'a> Eq for HostsPart<'a>[src]

impl<'a> PartialEq<HostsPart<'a>> for HostsPart<'a>[src]

impl<'a> StructuralEq for HostsPart<'a>[src]

impl<'a> StructuralPartialEq for HostsPart<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for HostsPart<'a>

impl<'a> Send for HostsPart<'a>

impl<'a> Sync for HostsPart<'a>

impl<'a> Unpin for HostsPart<'a>

impl<'a> UnwindSafe for HostsPart<'a>

Blanket Implementations

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

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

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

impl<T> Conv for T

impl<T> Conv for T

impl<T> FmtForward for T

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

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

impl<T> Pipe for T where
    T: ?Sized

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Tap for T

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

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

type Owned = T

The resulting type after obtaining ownership.

impl<T> TryConv for T

impl<T> TryConv for T

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.