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]

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 global() -> Self[src]

Return the entire IPv4 range, eg. 0.0.0.0/0

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]

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]

Returns the local subnet 192.168.x.0/24 where x is given by block.

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(&self) -> Ipv4Addr[src]

Get the netmask as an IP address

pub fn netmask_prefix_length(&self) -> u8[src]

Get the number of netmask prefix bits

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]

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]

Get a random IP address from the range which is not the base address or the default for the gateway address.

pub fn contains(&self, ip: Ipv4Addr) -> bool[src]

Check whether this range contains the given IP address

pub fn split(self, num: u32) -> Vec<Self>[src]

Split a range into num sub-ranges

Panics

If the range is too small to be split up that much.

Trait Implementations

impl Clone for Ipv4Range[src]

fn clone(&self) -> Ipv4Range[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Ipv4Range[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl From<Ipv4Addr> for Ipv4Range[src]

fn from(addr: Ipv4Addr) -> Self[src]

Performs the conversion.

impl From<Ipv4Range> for Ipv4Route[src]

fn from(range: Ipv4Range) -> Self[src]

Performs the conversion.

impl FromStr for Ipv4Range[src]

type Err = IpRangeParseError

The associated error which can be returned from parsing.

fn from_str(s: &str) -> Result<Ipv4Range, IpRangeParseError>[src]

Parses a string s to return a value of this type. Read more

impl Copy for Ipv4Range[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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]

🔬 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<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V