doido_cable/
connection.rs1use std::collections::BTreeMap;
8
9#[derive(Debug, Default, Clone)]
11pub struct CableConnection {
12 identifiers: BTreeMap<String, String>,
13 authorized: bool,
14}
15
16impl CableConnection {
17 pub fn new() -> Self {
18 Self::default()
19 }
20
21 pub fn identify(&mut self, key: &str, value: &str) -> &mut Self {
23 self.identifiers.insert(key.to_string(), value.to_string());
24 self
25 }
26
27 pub fn identifier(&self, key: &str) -> Option<&str> {
29 self.identifiers.get(key).map(String::as_str)
30 }
31
32 pub fn authorize(&mut self) -> &mut Self {
34 self.authorized = true;
35 self
36 }
37
38 pub fn reject(&mut self) -> &mut Self {
40 self.authorized = false;
41 self
42 }
43
44 pub fn is_authorized(&self) -> bool {
46 self.authorized
47 }
48}