January 2019
Intermediate to advanced
316 pages
8h 8m
English
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 ...