pub struct Cidr {
pub base: u32,
pub len: u8,
}Expand description
An IPv4 block, parsed from a.b.c.d/len and written back the same way (Display, FromStr).
Fields§
§base: u32The network address, as a number.
len: u8The prefix length.
Implementations§
Source§impl Cidr
impl Cidr
Sourcepub fn parse(s: &str) -> Option<Cidr>
pub fn parse(s: &str) -> Option<Cidr>
The block written a.b.c.d/len, when it is one: the address must be the network
address itself.
Sourcepub fn host(self, last_octet: u8) -> Option<Ipv4Addr>
pub fn host(self, last_octet: u8) -> Option<Ipv4Addr>
The address with this last octet, if it is a usable host address in the block.
Reserved on every target: .1 (gateway) and the two last usable addresses (controller, router).
Sourcepub fn gateway(self) -> Ipv4Addr
pub fn gateway(self) -> Ipv4Addr
The gateway’s address: the first usable address of the block (e.g. .1 in a /24).
Sourcepub fn gateway_octet(self) -> u8
pub fn gateway_octet(self) -> u8
The gateway’s last octet (1 in a /24, 9 in 10.0.0.8/29).
Sourcepub fn controller(self) -> Ipv4Addr
pub fn controller(self) -> Ipv4Addr
The controller’s address: the second-to-last usable one (e.g. .253 in a /24), where environment-level provisioning runs from.
Trait Implementations§
impl Copy for Cidr
impl Eq for Cidr
impl StructuralPartialEq for Cidr
Auto Trait Implementations§
impl Freeze for Cidr
impl RefUnwindSafe for Cidr
impl Send for Cidr
impl Sync for Cidr
impl Unpin for Cidr
impl UnsafeUnpin for Cidr
impl UnwindSafe for Cidr
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§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.