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(
16 &self,
17 f: &mut std::fmt::Formatter<'_>,
18 ) -> std::fmt::Result {
19 match self {
20 ConfigKey::Frontend => write!(f, "config_key_frontend"),
21 ConfigKey::FrontendForIp(_) => write!(f, "config_key_frontend_ip"),
22 }
23 }
24}
25
26impl ConfigKey {
27 pub(super) fn to_id(&self) -> (String, String, String) {
29 match self {
30 ConfigKey::Frontend => ("frontend".to_string(), String::new(), String::new()),
31 ConfigKey::FrontendForIp(ip) => {
32 ("frontend".to_string(), "ip".to_string(), ip.to_string())
33 },
34 }
35 }
36}