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