use std::collections::BTreeMap;
#[derive(Debug, Default, Clone)]
pub struct CableConnection {
identifiers: BTreeMap<String, String>,
authorized: bool,
}
impl CableConnection {
pub fn new() -> Self {
Self::default()
}
pub fn identify(&mut self, key: &str, value: &str) -> &mut Self {
self.identifiers.insert(key.to_string(), value.to_string());
self
}
pub fn identifier(&self, key: &str) -> Option<&str> {
self.identifiers.get(key).map(String::as_str)
}
pub fn authorize(&mut self) -> &mut Self {
self.authorized = true;
self
}
pub fn reject(&mut self) -> &mut Self {
self.authorized = false;
self
}
pub fn is_authorized(&self) -> bool {
self.authorized
}
}