pub struct IpRange {
pub subnet: IpNetwork,
pub range_start: Option<IpAddr>,
pub range_end: Option<IpAddr>,
pub gateway: Option<IpAddr>,
}Expand description
A range of IPs, usable for defining an IP pool.
The subnet is the only required field. The range can be further limited
with the range_start and range_end fields, which are inclusive.
§Examples
{"subnet": "10.0.0.0/8"}
{"subnet": "10.0.10.0/23", "rangeStart": "10.0.11.0", "rangeEnd": "10.0.11.254"}
{"subnet": "192.168.1.1/24", "gateway": "192.168.1.254"}Fields§
§subnet: IpNetworkThe subnet for the range.
range_start: Option<IpAddr>The start of the available range within the subnet, inclusive.
range_end: Option<IpAddr>The end of the available range within the subnet, inclusive.
gateway: Option<IpAddr>The gateway of the range.
Interpretation of an absent gateway is left to the implementation.
Implementations§
Source§impl IpRange
impl IpRange
Sourcepub fn iter_free(&self) -> impl Iterator<Item = (IpNetwork, &Self)>
pub fn iter_free(&self) -> impl Iterator<Item = (IpNetwork, &Self)>
Naive implementation of iterating the IP range.
This iterator will yield every IP available in the range, that is, every
IP in the subnet, except those lower than range_start, higher than
range_end, or the one which is the gateway.
The current implementation iterates through the entire range and filters
off the excluded IPs as per above. For IPv4 this will likely never be an
issue but IPv6 ranges are monstrous and could spend a long time spinning
before reaching range_start.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for IpRange
impl<'de> Deserialize<'de> for IpRange
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for IpRange
impl RefUnwindSafe for IpRange
impl Send for IpRange
impl Sync for IpRange
impl Unpin for IpRange
impl UnwindSafe for IpRange
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§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more