net_types::ip

Enum AddrSubnetEither

Source
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

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

§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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§

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

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.