Struct netsim_embed_core::Ipv4Range[][src]

pub struct Ipv4Range { /* fields omitted */ }
Expand description

A range of IPv4 addresses with a common prefix

Implementations

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)

Return the entire IPv4 range, eg. 0.0.0.0/0

Returns the local network subnet 10.0.0.0/8

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

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

Returns a random local network subnet from one of the ranges 10.0.0.0, 172.16.0.0 or 192.168.0.0

Get the netmask as an IP address

Get the number of netmask prefix bits

Get the base address of the range, ie. the lowest IP address which is part of the range.

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

Get the broadcast address, ie. the highest IP address which is part of the range.

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

Generate an IP address for a device.

Check whether this range contains the given IP address

Split a range into num sub-ranges

Panics

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

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

The associated error which can be returned from parsing.

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

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.