Storing network addresses is not a hard problem and there are many solutions out there. Their binary structure provides an opportunity to create something really specific—if time is not an issue.
In many cases, however, an off-the-shelf implementation of a data structure is enough to cover most basic use cases when that isn't your main concern. Hence, the network address storage can simple be a type alias that specifies the key type for the trie set, shown as follows:
pub type NetworkDeviceStore = TrieSet<u8>;
Slight modifications to the insert (former add) function of the trie allows users to simply pass a slice of the key type into the function, shown in the following code:
pub fn insert(&mut self, elements: &[K]) {
let mut path = elements.into_iter();
if let Some(start) = path.next() {
let mut n = self
.root
.entry(start.clone())
.or_insert(Node::new(start.clone(), false));
for...