use std::collections::HashMap;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct QosProfile {
pub reliable: bool,
pub depth: usize,
}
impl Default for QosProfile {
fn default() -> Self {
Self {
reliable: true,
depth: 16,
}
}
}
#[derive(Default)]
pub struct QosStore {
topics: HashMap<String, QosProfile>,
}
impl QosStore {
pub fn set_topic_qos(&mut self, topic: impl Into<String>, profile: QosProfile) {
self.topics.insert(topic.into(), profile);
}
pub fn set_topic_qos_if_absent(&mut self, topic: impl Into<String>, profile: QosProfile) {
self.topics.entry(topic.into()).or_insert(profile);
}
pub fn topic_qos(&self, topic: &str) -> Option<QosProfile> {
self.topics.get(topic).copied()
}
}