Struct net_route::Route

source ·
pub struct Route {
    pub destination: IpAddr,
    pub prefix: u8,
    pub gateway: Option<IpAddr>,
    pub ifindex: Option<u32>,
    pub table: u8,
}
Expand description

Contains information that describes a route in the local computer’s Ipv4 or Ipv6 routing table.

Fields§

§destination: IpAddr

Network address of the destination. 0.0.0.0 with a prefix of 0 is considered a default route.

§prefix: u8

Length of network prefix in the destination address.

§gateway: Option<IpAddr>

The address of the next hop of this route.

On macOS, this must be Some if ifindex is None

§ifindex: Option<u32>

The index of the local interface through which the next hop of this route may be reached.

On macOS, this must be Some if gateway is None

§table: u8

The routing table this route belongs to.

Implementations§

Create a route that matches a given destination network.

Either the gateway or interface should be set before attempting to add to a routing table.

Set the next next hop gateway for this route.

Set the index of the local interface through which the next hop of this route should be reached.

Set table the route will be installed in.

Get the netmask covering the network portion of the destination address.

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
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
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.