Struct netsim_embed_core::Ipv4Range [−][src]
pub struct Ipv4Range { /* fields omitted */ }
Expand description
A range of IPv4 addresses with a common prefix
Implementations
impl Ipv4Range
[src]
impl Ipv4Range
[src]pub fn new(addr: Ipv4Addr, bits: u8) -> Self
[src]
pub fn new(addr: Ipv4Addr, bits: u8) -> Self
[src]Create an IPv4 range with the given base address and netmask prefix length.
Example
Create the subnet 192.168.0.0/24 with Ipv4Range::new("192.168.0.0".parse().unwrap(), 24)
pub fn local_subnet_10() -> Self
[src]
pub fn local_subnet_10() -> Self
[src]Returns the local network subnet 10.0.0.0/8
pub fn local_subnet_172(block: u8) -> Self
[src]
pub fn local_subnet_172(block: u8) -> Self
[src]Returns a local network subnet 172.(16 | x).0.0/16 where x is a 4-bit number given by
block
Panics
If block & 0xf0 != 0
pub fn local_subnet_192(block: u8) -> Self
[src]
pub fn local_subnet_192(block: u8) -> Self
[src]Returns the local subnet 192.168.x.0/24 where x is given by block
.
pub fn random_local_subnet() -> Self
[src]
pub fn random_local_subnet() -> Self
[src]Returns a random local network subnet from one of the ranges 10.0.0.0, 172.16.0.0 or 192.168.0.0
pub fn netmask_prefix_length(&self) -> u8
[src]
pub fn netmask_prefix_length(&self) -> u8
[src]Get the number of netmask prefix bits
pub fn base_addr(&self) -> Ipv4Addr
[src]
pub fn base_addr(&self) -> Ipv4Addr
[src]Get the base address of the range, ie. the lowest IP address which is part of the range.
pub fn gateway_addr(&self) -> Ipv4Addr
[src]
pub fn gateway_addr(&self) -> Ipv4Addr
[src]Get a default IP address for the range’s gateway. This is one higher than the base address of the range. eg. for 10.0.0.0/8, the default address for the gateway will be 10.0.0.1
pub fn random_client_addr(&self) -> Ipv4Addr
[src]
pub fn random_client_addr(&self) -> Ipv4Addr
[src]Get a random IP address from the range which is not the base address or the default for the gateway address.
Trait Implementations
impl Copy for Ipv4Range
[src]
Auto Trait Implementations
impl RefUnwindSafe for Ipv4Range
impl Send for Ipv4Range
impl Sync for Ipv4Range
impl Unpin for Ipv4Range
impl UnwindSafe for Ipv4Range
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,