atm0s_sdn_network/features/
mod.rs1pub mod alias;
2pub mod data;
3pub mod dht_kv;
4pub mod neighbours;
5pub mod pubsub;
6pub mod router_sync;
7pub mod socket;
8pub mod vpn;
9
10#[derive(Debug, Clone, Copy, PartialEq, Eq, num_enum::TryFromPrimitive, num_enum::IntoPrimitive)]
16#[repr(u8)]
17pub enum Features {
18 Neighbours = neighbours::FEATURE_ID,
19 Data = data::FEATURE_ID,
20 RouterSync = router_sync::FEATURE_ID,
21 Vpn = vpn::FEATURE_ID,
22 DhtKv = dht_kv::FEATURE_ID,
23 PubSub = pubsub::FEATURE_ID,
24 Alias = alias::FEATURE_ID,
25 Socket = socket::FEATURE_ID,
26}
27
28#[derive(Debug, Clone, PartialEq, Eq, convert_enum::From)]
29pub enum FeaturesControl {
30 Neighbours(neighbours::Control),
31 Data(data::Control),
32 RouterSync(router_sync::Control),
33 Vpn(vpn::Control),
34 DhtKv(dht_kv::Control),
35 PubSub(pubsub::Control),
36 Alias(alias::Control),
37 Socket(socket::Control),
38}
39
40impl FeaturesControl {
41 pub fn to_feature(&self) -> Features {
42 match self {
43 Self::Neighbours(_) => Features::Neighbours,
44 Self::Data(_) => Features::Data,
45 Self::RouterSync(_) => Features::RouterSync,
46 Self::Vpn(_) => Features::Vpn,
47 Self::DhtKv(_) => Features::DhtKv,
48 Self::PubSub(_) => Features::PubSub,
49 Self::Alias(_) => Features::Alias,
50 Self::Socket(_) => Features::Socket,
51 }
52 }
53}
54
55#[derive(Debug, Clone, PartialEq, Eq, convert_enum::From)]
56pub enum FeaturesEvent {
57 Neighbours(neighbours::Event),
58 Data(data::Event),
59 RouterSync(router_sync::Event),
60 Vpn(vpn::Event),
61 DhtKv(dht_kv::Event),
62 PubSub(pubsub::Event),
63 Alias(alias::Event),
64 Socket(socket::Event),
65}
66
67#[derive(Debug, Clone, convert_enum::From)]
68pub enum FeaturesToController {
69 Neighbours(neighbours::ToController),
70 Data(data::ToController),
71 RouterSync(router_sync::ToController),
72 Vpn(vpn::ToController),
73 DhtKv(dht_kv::ToController),
74 PubSub(pubsub::ToController),
75 Alias(alias::ToController),
76 Socket(socket::ToController),
77}
78
79impl FeaturesToController {
80 pub fn to_feature(&self) -> Features {
81 match self {
82 Self::Neighbours(_) => Features::Neighbours,
83 Self::Data(_) => Features::Data,
84 Self::RouterSync(_) => Features::RouterSync,
85 Self::Vpn(_) => Features::Vpn,
86 Self::DhtKv(_) => Features::DhtKv,
87 Self::PubSub(_) => Features::PubSub,
88 Self::Alias(_) => Features::Alias,
89 Self::Socket(_) => Features::Socket,
90 }
91 }
92}
93
94#[derive(Debug, Clone, convert_enum::From)]
95pub enum FeaturesToWorker<UserData> {
96 Neighbours(neighbours::ToWorker),
97 Data(data::ToWorker),
98 RouterSync(router_sync::ToWorker),
99 Vpn(vpn::ToWorker),
100 DhtKv(dht_kv::ToWorker),
101 PubSub(pubsub::ToWorker<UserData>),
102 Alias(alias::ToWorker),
103 Socket(socket::ToWorker<UserData>),
104}
105
106impl<UserData> FeaturesToWorker<UserData> {
107 pub fn to_feature(&self) -> Features {
108 match self {
109 Self::Neighbours(_) => Features::Neighbours,
110 Self::Data(_) => Features::Data,
111 Self::RouterSync(_) => Features::RouterSync,
112 Self::Vpn(_) => Features::Vpn,
113 Self::DhtKv(_) => Features::DhtKv,
114 Self::PubSub(_) => Features::PubSub,
115 Self::Alias(_) => Features::Alias,
116 Self::Socket(_) => Features::Socket,
117 }
118 }
119}