pub struct Subnet<A> { /* private fields */ }
Expand description
An IP subnet.
Subnet
is a combination of an IP network address and a prefix length.
Implementations§
Source§impl<A> Subnet<A>
impl<A> Subnet<A>
Sourcepub const unsafe fn new_unchecked(network: A, prefix: u8) -> Subnet<A>
pub const unsafe fn new_unchecked(network: A, prefix: u8) -> Subnet<A>
Creates a new subnet without enforcing correctness.
§Safety
Unlike new
, new_unchecked
does not validate that prefix
is in the
proper range, and does not check that network
has only the top
prefix
bits set. It is up to the caller to guarantee that prefix
is
in the proper range, and that none of the bits of network
beyond the
prefix are set.
Source§impl<A: IpAddress> Subnet<A>
impl<A: IpAddress> Subnet<A>
Sourcepub fn new(network: A, prefix: u8) -> Result<Subnet<A>, SubnetError>
pub fn new(network: A, prefix: u8) -> Result<Subnet<A>, 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: A, prefix: u8) -> Result<Subnet<A>, PrefixTooLongError>
pub fn from_host(host: A, prefix: u8) -> Result<Subnet<A>, PrefixTooLongError>
Creates a new subnet from the address of a host in that subnet.
Unlike new
, the host
address may have host bits set.
Trait Implementations§
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
Source§impl<A, I: Ip> GenericOverIp<I> for Subnet<A>
impl<A, I: Ip> GenericOverIp<I> for Subnet<A>
Source§impl<A: Ord> Ord for Subnet<A>
impl<A: Ord> Ord for Subnet<A>
Subnet ordering always orders from least-specific to most-specific subnet.
Source§impl<A: Ord> PartialOrd for Subnet<A>
impl<A: Ord> PartialOrd for Subnet<A>
impl<A: Copy> Copy for Subnet<A>
impl<A: Eq> Eq for Subnet<A>
impl<A> StructuralPartialEq for Subnet<A>
Auto Trait Implementations§
impl<A> Freeze for Subnet<A>where
A: Freeze,
impl<A> RefUnwindSafe for Subnet<A>where
A: RefUnwindSafe,
impl<A> Send for Subnet<A>where
A: Send,
impl<A> Sync for Subnet<A>where
A: Sync,
impl<A> Unpin for Subnet<A>where
A: Unpin,
impl<A> UnwindSafe for Subnet<A>where
A: UnwindSafe,
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
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)
clone_to_uninit
)