pub enum AddrSubnetEither<A: IpAddrWitness = SpecifiedAddr<IpAddr>> {
    V4(AddrSubnet<Ipv4Addr, A::V4>),
    V6(AddrSubnet<Ipv6Addr, A::V6>),
}
Expand description

An address and that address’s subnet, either IPv4 or IPv6.

AddrSubnetEither is an enum of AddrSubnet<Ipv4Addr> and AddrSubnet<Ipv6Addr>.

Variants§

Implementations§

source§

impl<A: IpAddrWitness> AddrSubnetEither<A>

source

pub fn new( addr: IpAddr, prefix: u8 ) -> Result<AddrSubnetEither<A>, AddrSubnetError>

Creates a new AddrSubnetEither.

new creates a new AddrSubnetEither with the given address and prefix length. It returns Err under the same conditions as AddrSubnet::new.

source

pub unsafe fn new_unchecked(addr: IpAddr, prefix: u8) -> Self

Creates a new AddrSubnetEither from trusted inputs.

§Safety

Unlike new, this assumes that the provided address satisfies the requirements of the witness type A, and that prefix is not too large for the IP version of the address in addr.

source

pub fn addr(&self) -> A

Gets the IP address.

source

pub fn addr_prefix(&self) -> (A, u8)

Gets the IP address and prefix.

source

pub fn addr_subnet(&self) -> (A, SubnetEither)

Gets the IP address and subnet.

Trait Implementations§

source§

impl<A: Clone + IpAddrWitness> Clone for AddrSubnetEither<A>
where A::V4: Clone, A::V6: Clone,

source§

fn clone(&self) -> AddrSubnetEither<A>

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<A: Debug + IpAddrWitness> Debug for AddrSubnetEither<A>
where A::V4: Debug, A::V6: Debug,

source§

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

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

impl<A> Display for AddrSubnetEither<A>
where A: IpAddrWitness, A::V4: Display, A::V6: Display,

source§

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

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

impl<S: IpAddress, A: IpAddressWitness<S> + Copy> From<AddrSubnet<S, A>> for AddrSubnetEither<A::IpAddrWitness>

source§

fn from(addr_sub: AddrSubnet<S, A>) -> AddrSubnetEither<A::IpAddrWitness>

Converts to this type from the input type.
source§

impl<A: Hash + IpAddrWitness> Hash for AddrSubnetEither<A>
where A::V4: Hash, A::V6: Hash,

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<A: PartialEq + IpAddrWitness> PartialEq for AddrSubnetEither<A>
where A::V4: PartialEq, A::V6: PartialEq,

source§

fn eq(&self, other: &AddrSubnetEither<A>) -> 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<A: Copy + IpAddrWitness> Copy for AddrSubnetEither<A>
where A::V4: Copy, A::V6: Copy,

source§

impl<A: Eq + IpAddrWitness> Eq for AddrSubnetEither<A>
where A::V4: Eq, A::V6: Eq,

source§

impl<A: IpAddrWitness> StructuralPartialEq for AddrSubnetEither<A>

Auto Trait Implementations§

§

impl<A> RefUnwindSafe for AddrSubnetEither<A>

§

impl<A> Send for AddrSubnetEither<A>
where <A as IpAddrWitness>::V4: Send, <A as IpAddrWitness>::V6: Send,

§

impl<A> Sync for AddrSubnetEither<A>
where <A as IpAddrWitness>::V4: Sync, <A as IpAddrWitness>::V6: Sync,

§

impl<A> Unpin for AddrSubnetEither<A>
where <A as IpAddrWitness>::V4: Unpin, <A as IpAddrWitness>::V6: Unpin,

§

impl<A> UnwindSafe for AddrSubnetEither<A>

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

§

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.