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>
Subnet ordering always orders from least-specific to most-specific subnet.
impl<A: Ord> Ord for Subnet<A>
Subnet ordering always orders from least-specific to most-specific subnet.