cat_gateway/db/event/config/
key.rs1use std::{fmt::Display, net::IpAddr};
4
5#[derive(Debug, Clone, PartialEq)]
7pub(crate) enum ConfigKey {
8 Frontend,
10 FrontendForIp(IpAddr),
12}
13
14impl Display for ConfigKey {
15 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
16 match self {
17 ConfigKey::Frontend => write!(f, "config_key_frontend"),
18 ConfigKey::FrontendForIp(_) => write!(f, "config_key_frontend_ip"),
19 }
20 }
21}
22
23impl ConfigKey {
24 pub(super) fn to_id(&self) -> (String, String, String) {
26 match self {
27 ConfigKey::Frontend => ("frontend".to_string(), String::new(), String::new()),
28 ConfigKey::FrontendForIp(ip) => {
29 ("frontend".to_string(), "ip".to_string(), ip.to_string())
30 },
31 }
32 }
33}