It is possible that there exists a key of type u64
within either one of the two hashmaps contained within self
. The same key cannot contain an entry in both hashmaps. I run a match against a tuple as such:
fn start_send(&mut self, item: Self::SinkItem) -> Result<AsyncSink<Self::SinkItem>, Self::SinkError> {
let eid_oid = item.get_header().oid_eid.get();
if eid_oid != 0 {
match (self.object_expectancies.get_mut(&eid_oid), self.singleton_expectancies.get_mut(&eid_oid)) {
(Some(exp), None) => {
exp.deliver_packet(item).or_else(|_| {
item.stage = PacketStage::NeedsDelete
});
},
(None, Some(exp)) => {
exp.deliver_packet(item).or_else(|_| {
item.stage = PacketStage::NeedsDelete
});
},
_ => {
/// a packet was sent to this node, but localhost did not expect this eid_oid. TODO: implement packet forwarding system
}
}
} else {
// This implies a packet was sent to this node without an expectation of being responded to. Enqueue it for stage 3
self.fifo.push_back(item);
}
Ok(AsyncSink::Ready)
}