pub struct Cidr<A> { /* private fields */ }Expand description
CIDR representation of IPv4 network
Implementations§
Source§impl<A: NetworkAddress> Cidr<A>
impl<A: NetworkAddress> Cidr<A>
Source§impl Cidr<Ipv4Addr>
impl Cidr<Ipv4Addr>
Sourcepub const fn network_addr(&self) -> Ipv4Addr
pub const fn network_addr(&self) -> Ipv4Addr
Computes network address from provided addr and prefix, which is lowest possible address within CIDR block
Sourcepub const fn broadcast_addr(&self) -> Ipv4Addr
pub const fn broadcast_addr(&self) -> Ipv4Addr
Computes network address from provided addr and prefix, which is highest possible address within CIDR block
Sourcepub const fn contains(&self, addr: Ipv4Addr) -> bool
pub const fn contains(&self, addr: Ipv4Addr) -> bool
Checks if a given addr is contained within self
Sourcepub const fn get(&self, idx: u32) -> Option<Ipv4Addr>
pub const fn get(&self, idx: u32) -> Option<Ipv4Addr>
Attempts to fetch address by idx within the block self
Sourcepub const fn get_unchecked(&self, idx: u32) -> Ipv4Addr
pub const fn get_unchecked(&self, idx: u32) -> Ipv4Addr
Returns address corresponding idx without checking size according to the prefix
This is safe in a sense as it is only wrapping math operation, but it should be only used when you know need to iterate over possible addresses by pre-computing size
Source§impl Cidr<Ipv6Addr>
impl Cidr<Ipv6Addr>
Sourcepub const fn network_addr(&self) -> Ipv6Addr
pub const fn network_addr(&self) -> Ipv6Addr
Computes network address from provided addr and prefix, which is lowest possible address within CIDR block
Sourcepub const fn broadcast_addr(&self) -> Ipv6Addr
pub const fn broadcast_addr(&self) -> Ipv6Addr
Computes network address from provided addr and prefix, which is highest possible address within CIDR block
Sourcepub const fn contains(&self, addr: Ipv6Addr) -> bool
pub const fn contains(&self, addr: Ipv6Addr) -> bool
Checks if a given addr is contained within self
Sourcepub const fn get(&self, idx: u128) -> Option<Ipv6Addr>
pub const fn get(&self, idx: u128) -> Option<Ipv6Addr>
Attempts to fetch address by idx within the block self
Sourcepub const fn get_unchecked(&self, idx: u128) -> Ipv6Addr
pub const fn get_unchecked(&self, idx: u128) -> Ipv6Addr
Returns address corresponding idx without checking size according to the prefix
This is safe in a sense as it is only wrapping math operation, but it should be only used when you know need to iterate over possible addresses by pre-computing size