Skip to main content

libcgroups/systemd/
controller_type.rs

1use std::fmt::Display;
2
3pub enum ControllerType {
4    Cpu,
5    CpuSet,
6    Io,
7    Memory,
8    Pids,
9}
10
11impl Display for ControllerType {
12    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
13        let print = match self {
14            ControllerType::Cpu => "cpu",
15            ControllerType::CpuSet => "cpuset",
16            ControllerType::Io => "io",
17            ControllerType::Memory => "memory",
18            ControllerType::Pids => "pids",
19        };
20
21        write!(f, "{print}")
22    }
23}
24
25impl AsRef<str> for ControllerType {
26    fn as_ref(&self) -> &str {
27        match self {
28            ControllerType::Cpu => "cpu",
29            ControllerType::CpuSet => "cpuset",
30            ControllerType::Io => "io",
31            ControllerType::Memory => "memory",
32            ControllerType::Pids => "pids",
33        }
34    }
35}
36
37pub const CONTROLLER_TYPES: &[ControllerType] = &[
38    ControllerType::Cpu,
39    ControllerType::CpuSet,
40    ControllerType::Io,
41    ControllerType::Memory,
42    ControllerType::Pids,
43];