Enum net_types::ip::SubnetEither
source · pub enum SubnetEither {
V4(Subnet<Ipv4Addr>),
V6(Subnet<Ipv6Addr>),
}
Expand description
An IPv4 subnet or an IPv6 subnet.
SubnetEither
is an enum of Subnet<Ipv4Addr>
and Subnet<Ipv6Addr>
.
Variants§
Implementations§
source§impl SubnetEither
impl SubnetEither
sourcepub fn new(network: IpAddr, prefix: u8) -> Result<SubnetEither, SubnetError>
pub fn new(network: IpAddr, prefix: u8) -> Result<SubnetEither, SubnetError>
Creates a new subnet.
new
creates a new subnet with the given network address and prefix
length. It returns Err
if prefix
is longer than the number of bits
in this type of IP address (32 for IPv4 and 128 for IPv6) or if any of
the host bits (beyond the first prefix
bits) are set in network
.
sourcepub fn from_host(
host: IpAddr,
prefix: u8,
) -> Result<SubnetEither, PrefixTooLongError>
pub fn from_host( host: IpAddr, prefix: u8, ) -> Result<SubnetEither, PrefixTooLongError>
Creates a new subnet from the address of a host in that subnet.
Unlike new
, the host
address may have host bits set.
sourcepub fn net_prefix(&self) -> (IpAddr, u8)
pub fn net_prefix(&self) -> (IpAddr, u8)
Gets the network and prefix.
Trait Implementations§
source§impl Clone for SubnetEither
impl Clone for SubnetEither
source§fn clone(&self) -> SubnetEither
fn clone(&self) -> SubnetEither
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for SubnetEither
impl Debug for SubnetEither
source§impl<A: IpAddress> From<Subnet<A>> for SubnetEither
impl<A: IpAddress> From<Subnet<A>> for SubnetEither
source§fn from(subnet: Subnet<A>) -> SubnetEither
fn from(subnet: Subnet<A>) -> SubnetEither
Converts to this type from the input type.
source§impl Hash for SubnetEither
impl Hash for SubnetEither
source§impl PartialEq for SubnetEither
impl PartialEq for SubnetEither
source§fn eq(&self, other: &SubnetEither) -> bool
fn eq(&self, other: &SubnetEither) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Copy for SubnetEither
impl Eq for SubnetEither
impl StructuralPartialEq for SubnetEither
Auto Trait Implementations§
impl Freeze for SubnetEither
impl RefUnwindSafe for SubnetEither
impl Send for SubnetEither
impl Sync for SubnetEither
impl Unpin for SubnetEither
impl UnwindSafe for SubnetEither
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)