Add method to get selected route from RouteList

Signed-off-by: Lee Smet <lee.smet@hotmail.com>
This commit is contained in:
Lee Smet committed 2024-06-28 10:28:58 +02:00
1 parent 3d0b518794
commit 09d2eaa2e0
1 file changed
+8
+8
View File
@@ -173,6 +173,14 @@ impl RouteList {
.map(|(_, e)| e)
.find(|entry| entry.neighbour == route_key.neighbour)
}
/// Returns the selected route for the [`Subnet`] this is the `RouteList` for, if one exists.
pub fn selected(&self) -> Option<&RouteEntry> {
self.list
.get(0)
.map(|(_, re)| re)
.and_then(|re| if re.selected { Some(re) } else { None })
}
}
/// A guard which allows write access to a single [`RouteEntry`].