Skip to main content

RoutingTableExt

Trait RoutingTableExt 

Source
pub trait RoutingTableExt: RoutingTable + Sealed {
    // Provided method
    fn modify(
        &mut self,
        prefix: IpNet,
        modify: impl FnOnce(Option<&mut Self::Value>) -> RouteModification<Self::Value>,
    ) -> Option<Self::Value> { ... }
}
Expand description

Automatic extension methods for implementors of RoutingTable.

Provided Methods§

Source

fn modify( &mut self, prefix: IpNet, modify: impl FnOnce(Option<&mut Self::Value>) -> RouteModification<Self::Value>, ) -> Option<Self::Value>

Modify the route at prefix using the modify closure.

The closure may return:

If the route was replaced or removed, the return value contains the value that was previously stored.

Prefer to use insert or remove if possible; this function is intended as a more-efficient alternative to lookup_prefix_exact-then-mutate.

§Examples
let mut table = SimpleTable::default();
let result = table.modify("0.0.0.0/0".parse().unwrap(), |node| {
    assert_eq!(None, node);
    RouteModification::Insert(4)
});
assert_eq!(None, result);
assert_eq!(Some(&4), table.lookup("1.2.3.4".parse().unwrap()));

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T> RoutingTableExt for T
where T: RoutingTable,