Typically, heaps are used as priority queues of all kinds. Queues like that exist in any resource-constrained environment (and everywhere else, probably), but their purpose is to output things in an ordered fashion. By using the number of messages to determine the priority of a message notification, the heap can do the heavy lifting of this feature. Before jumping into the hard stuff, though, here are the bits containing the information:
#[derive(Clone, Debug)]
pub struct MessageNotification {
pub no_messages: u64,
pub device: IoTDevice,
}
The idea is to use the number of messages as an indicator of which device to poll first, which is why the device is required. Using this type, the heap does not require any specific node or link types to work:
pub struct MessageChecker {
pub length: usize,
heap: Vec<Box<MessageNotification>>,
}
There are two interesting points here: the underlying structure is a regular Vec<T>, which was chosen for its expansion...