pub struct Routes { /* private fields */ }Expand description
A routing table.
Implementations§
Source§impl Routes
impl Routes
Sourcepub fn add(&mut self, route: Route) -> Result<(), Full>
pub fn add(&mut self, route: Route) -> Result<(), Full>
Add a route.
Errors:
Fullif the table has no room. Only possible without theallocfeature, where the limit isROUTE_COUNT.
Sourcepub fn retain(&mut self, f: impl FnMut(&Route) -> bool)
pub fn retain(&mut self, f: impl FnMut(&Route) -> bool)
Keep only the routes for which f returns true.
Sourcepub fn iter_mut(&mut self) -> impl Iterator<Item = &mut Route>
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut Route>
Iterate over the routes, mutably.
Sourcepub fn add_default_ipv4_route(
&mut self,
gateway: Ipv4Address,
iface: IfaceHandle,
) -> Result<Option<Route>, Full>
pub fn add_default_ipv4_route( &mut self, gateway: Ipv4Address, iface: IfaceHandle, ) -> Result<Option<Route>, Full>
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.
Errors:
Fullif the table has no room. Only possible without theallocfeature, where the limit isROUTE_COUNT.
Sourcepub fn add_default_ipv6_route(
&mut self,
gateway: Ipv6Address,
iface: IfaceHandle,
) -> Result<Option<Route>, Full>
pub fn add_default_ipv6_route( &mut self, gateway: Ipv6Address, iface: IfaceHandle, ) -> Result<Option<Route>, Full>
Add a default ipv6 gateway (ie. “ip -6 route add ::/0 via gateway dev iface”).
Returns the previous default route, if any.
Errors:
Fullif the table has no room. Only possible without theallocfeature, where the limit isROUTE_COUNT.
Sourcepub fn get_default_ipv4_route(&self) -> Option<Route>
pub fn get_default_ipv4_route(&self) -> Option<Route>
Returns the ipv4 default route if there is one in the route table.
Sourcepub fn get_default_ipv6_route(&self) -> Option<Route>
pub fn get_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(&mut self) -> Option<Route>
pub fn remove_default_ipv4_route(&mut self) -> Option<Route>
Remove the default ipv4 gateway, returning it if it existed.
Sourcepub fn remove_default_ipv6_route(&mut self) -> Option<Route>
pub fn remove_default_ipv6_route(&mut self) -> Option<Route>
Remove the default ipv6 gateway, returning it if it existed.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Routes
impl RefUnwindSafe for Routes
impl Send for Routes
impl Sync for Routes
impl Unpin for Routes
impl UnsafeUnpin for Routes
impl UnwindSafe for Routes
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