#[derive(Debug)]
#[derive(Deserialize, Serialize)]
pub struct StaticRoutingTableConfiguration<NetworkAddress: InternetProtocolNetworkAddress>
where <NetworkAddress as InternetProtocolNetworkAddress>::HostAddress: DeserializeOwned
{
pub static_routes: HashMap<NetworkAddress, Route<NetworkAddress::HostAddress>>,
pub default_route_to_next_hop: EthernetDestination,
}
impl<NetworkAddress: InternetProtocolNetworkAddress> StaticRoutingTableConfiguration<NetworkAddress>
where <NetworkAddress as InternetProtocolNetworkAddress>::HostAddress: DeserializeOwned
{
#[inline(always)]
pub fn configure(mut self) -> StaticRoutingTable<NetworkAddress>
{
StaticRoutingTable
{
longest_prefix_match:
{
let mut tree_bitmap: TreeBitmap<Route<NetworkAddress::HostAddress>> = TreeBitmap::with_capacity(self.static_routes.len());
for (network_address, static_route) in self.static_routes.drain()
{
let mask_length = network_address.mask_bits_as_depth_u32();
let nibbles = network_address.network().nibbles();
tree_bitmap.insert(nibbles.as_ref(), mask_length, static_route);
}
tree_bitmap
},
default_route_to_next_hop: self.default_route_to_next_hop,
}
}
}