wasmcloud_runtime/
experimental.rs1use tracing::warn;
2
3#[derive(Copy, Clone, Debug, Default)]
6pub struct Features {
7 pub wasmcloud_messaging_v3: bool,
9 pub workload_identity_interface: bool,
11}
12
13impl Features {
14 #[must_use]
16 pub fn new() -> Self {
17 Self::default()
18 }
19
20 #[must_use]
22 pub fn enable_wasmcloud_messaging_v3(mut self) -> Self {
23 self.wasmcloud_messaging_v3 = true;
24 self
25 }
26
27 #[must_use]
29 pub fn enable_workload_identity_interface(mut self) -> Self {
30 self.workload_identity_interface = true;
31 self
32 }
33}
34
35impl std::ops::BitOr for Features {
37 type Output = Self;
38
39 fn bitor(self, rhs: Self) -> Self::Output {
40 Self {
41 wasmcloud_messaging_v3: self.wasmcloud_messaging_v3 || rhs.wasmcloud_messaging_v3,
42 workload_identity_interface: self.workload_identity_interface
43 || rhs.workload_identity_interface,
44 }
45 }
46}
47
48impl std::iter::Sum for Features {
50 fn sum<I: Iterator<Item = Self>>(mut iter: I) -> Self {
51 let first = iter.next().unwrap_or_default();
53 iter.fold(first, |a, b| a | b)
54 }
55}
56
57impl From<&str> for Features {
59 fn from(s: &str) -> Self {
60 match &*s.to_ascii_lowercase() {
61 "wasmcloud-messaging-v3" | "wasmcloud_messaging_v3" => {
62 Self::new().enable_wasmcloud_messaging_v3()
63 }
64 "workload-identity-interface" | "workload_identity_interface" => {
65 Self::new().enable_workload_identity_interface()
66 }
67 _ => {
68 warn!(%s, "unknown feature flag");
69 Self::new()
70 }
71 }
72 }
73}