workflow_log/
console.rs

1#[cfg(not(target_arch = "bpf"))]
2pub use console::style;
3
4#[cfg(target_arch = "bpf")]
5mod console_style {
6    use std::fmt::*;
7
8    pub struct ConsoleStyle<'t>(pub &'t str);
9
10    impl<'t> ConsoleStyle<'t> {
11        pub fn black(&'t self) -> &'t Self {
12            self
13        }
14        pub fn white(&'t self) -> &'t Self {
15            self
16        }
17        pub fn red(&'t self) -> &'t Self {
18            self
19        }
20        pub fn green(&'t self) -> &'t Self {
21            self
22        }
23        pub fn blue(&'t self) -> &'t Self {
24            self
25        }
26        pub fn yellow(&'t self) -> &'t Self {
27            self
28        }
29        pub fn cyan(&'t self) -> &'t Self {
30            self
31        }
32        pub fn magenta(&'t self) -> &'t Self {
33            self
34        }
35        pub fn color256(&'t self) -> &'t Self {
36            self
37        }
38
39        pub fn on_black(&'t self) -> &'t Self {
40            self
41        }
42        pub fn on_white(&'t self) -> &'t Self {
43            self
44        }
45        pub fn on_red(&'t self) -> &'t Self {
46            self
47        }
48        pub fn on_green(&'t self) -> &'t Self {
49            self
50        }
51        pub fn on_blue(&'t self) -> &'t Self {
52            self
53        }
54        pub fn on_yellow(&'t self) -> &'t Self {
55            self
56        }
57        pub fn on_cyan(&'t self) -> &'t Self {
58            self
59        }
60        pub fn on_magenta(&'t self) -> &'t Self {
61            self
62        }
63    }
64
65    impl<'t> Display for ConsoleStyle<'t> {
66        fn fmt(&self, f: &mut Formatter) -> Result {
67            write!(f, "{}", self.0)
68        }
69    }
70
71    // #[cfg(target_arch = "bpf")]
72    // impl<'t> Into<&'t str> for ConsoleStyle<'t> {
73    //     fn into(self) -> &'t str { self.text }
74    // }
75}
76
77#[cfg(target_arch = "bpf")]
78pub fn style<'t>(text: &'t str) -> console_style::ConsoleStyle<'t> {
79    console_style::ConsoleStyle(text)
80}
81
82cfg_if::cfg_if! {
83    if #[cfg(target_arch = "bpf")] {
84        pub fn set_colors_enabled(_:bool) { }
85    } else {
86        pub fn set_colors_enabled(enable: bool) {
87            console::set_colors_enabled(enable)
88        }
89    }
90}