pub struct Routes<'d> { /* private fields */ }Expand description
A routing table, returned by Stack::routes.
Implementations§
Source§impl<'d> Routes<'d>
impl<'d> Routes<'d>
Sourcepub fn add(&self, route: Route) -> Result<(), RouteError>
pub fn add(&self, route: Route) -> Result<(), RouteError>
Add a route.
§Errors
NotUnicast: ifvia_routeris not a unicast address.Full: if the table has no room. Only possible without theallocfeature, where the limit isROUTE_COUNT.
Sourcepub fn retain(&self, f: impl FnMut(&Route) -> bool)
pub fn retain(&self, f: impl FnMut(&Route) -> bool)
Keep only the routes for which f returns true.
Sourcepub fn add_default_ipv4_route(
&self,
gateway: Ipv4Addr,
iface: IfaceHandle,
) -> Result<Option<Route>, RouteError>
pub fn add_default_ipv4_route( &self, gateway: Ipv4Addr, iface: IfaceHandle, ) -> Result<Option<Route>, RouteError>
Add a default ipv4 gateway (ie. “ip route add 0.0.0.0/0 via gateway dev iface”).
Returns the previous default route, if any. On error the previous default route is kept.
§Errors
NotUnicast: ifgatewayis not a unicast address.Full: if the table has no room. Only possible without theallocfeature, where the limit isROUTE_COUNT.
Sourcepub fn add_default_ipv6_route(
&self,
gateway: Ipv6Addr,
iface: IfaceHandle,
) -> Result<Option<Route>, RouteError>
pub fn add_default_ipv6_route( &self, gateway: Ipv6Addr, iface: IfaceHandle, ) -> Result<Option<Route>, RouteError>
Add a default ipv6 gateway (ie. “ip -6 route add ::/0 via gateway dev iface”).
Returns the previous default route, if any. On error the previous default route is kept.
§Errors
NotUnicast: ifgatewayis not a unicast address.Full: if the table has no room. Only possible without theallocfeature, where the limit isROUTE_COUNT.
Sourcepub fn default_ipv4_route(&self) -> Option<Route>
pub fn default_ipv4_route(&self) -> Option<Route>
Returns the ipv4 default route if there is one in the route table.
Sourcepub fn default_ipv6_route(&self) -> Option<Route>
pub fn default_ipv6_route(&self) -> Option<Route>
Returns the ipv6 default route if there is one in the route table.
Sourcepub fn remove_default_ipv4_route(&self) -> Option<Route>
pub fn remove_default_ipv4_route(&self) -> Option<Route>
Remove the default ipv4 gateway, returning it if it existed.
Sourcepub fn remove_default_ipv6_route(&self) -> Option<Route>
pub fn remove_default_ipv6_route(&self) -> Option<Route>
Remove the default ipv6 gateway, returning it if it existed.
Trait Implementations§
Auto Trait Implementations§
impl<'d> !RefUnwindSafe for Routes<'d>
impl<'d> !Send for Routes<'d>
impl<'d> !Sync for Routes<'d>
impl<'d> !UnwindSafe for Routes<'d>
impl<'d> Freeze for Routes<'d>
impl<'d> Unpin for Routes<'d>
impl<'d> UnsafeUnpin for Routes<'d>
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
Mutably borrows from an owned value. Read more