1use std::fmt::Display;
2
3#[cfg(feature = "orm")]
4use sea_orm::{DeriveActiveEnum, EnumIter};
5use serde::{Deserialize, Serialize};
6
7#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
11#[cfg_attr(feature = "cli", derive(clap::ValueEnum))]
12#[cfg_attr(feature = "orm", derive(EnumIter, DeriveActiveEnum))]
13#[cfg_attr(feature = "orm", sea_orm(rs_type = "i32", db_type = "Integer"))]
14pub enum ConnectionAction {
15 #[cfg_attr(feature = "orm", sea_orm(num_value = 0))]
17 Allow,
18
19 #[cfg_attr(feature = "orm", sea_orm(num_value = 1))]
21 Deny,
22}
23
24impl ConnectionAction {
25 pub fn as_str(&self) -> &'static str {
26 match self {
27 ConnectionAction::Allow => "allow",
28 ConnectionAction::Deny => "deny",
29 }
30 }
31}
32
33impl Display for ConnectionAction {
34 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
35 write!(f, "{}", self.as_str())
36 }
37}
38
39#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
40#[cfg_attr(feature = "cli", derive(clap::ValueEnum))]
41#[cfg_attr(feature = "orm", derive(EnumIter, DeriveActiveEnum))]
42#[cfg_attr(feature = "orm", sea_orm(rs_type = "i32", db_type = "Integer"))]
43pub enum RequestAction {
44 #[cfg_attr(feature = "orm", sea_orm(num_value = 0))]
46 Allow,
47 #[cfg_attr(feature = "orm", sea_orm(num_value = 1))]
49 Deny,
50}
51
52impl RequestAction {
53 fn as_str(&self) -> &'static str {
54 match self {
55 RequestAction::Allow => "allow",
56 RequestAction::Deny => "deny",
57 }
58 }
59}
60
61impl Display for RequestAction {
62 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
63 write!(f, "{}", self.as_str())
64 }
65}