Paths like that tend to have a huge overlap, since there are countless sensors and devices in a single location. Additionally, they are unique thanks to the hierarchical properties and are human-readable in case the sensor needs to be found. A great fit for a trie!
The basis for this trie will be a node type that stores the children, current character, and, if it's a node that concludes a full key, the IoTDevice object from earlier in this chapter. This is what this looks like in Rust:
struct Node {
pub key: char,
next: HashMap<char, Link>,
pub value: Option<IoTDevice>,
}
This time, the children is a different data structure as well: a HashMap. Maps (also called dictionaries, associative arrays) explicitly store a key alongside a value and the word "hash" hints at the method, which will be discussed in the next chapter. For now, the HashMap guarantees a single character to be associated with a Node type, leading the...