libcgroups/v1/
controller_type.rs1use std::fmt::Display;
2
3#[derive(Hash, PartialEq, Eq, Debug, Clone, Copy)]
4pub enum ControllerType {
5 Cpu,
6 CpuAcct,
7 CpuSet,
8 Devices,
9 HugeTlb,
10 Pids,
11 PerfEvent,
12 Memory,
13 Blkio,
14 NetworkPriority,
15 NetworkClassifier,
16 Freezer,
17}
18
19impl Display for ControllerType {
20 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21 let print = match *self {
22 Self::Cpu => "cpu",
23 Self::CpuAcct => "cpuacct",
24 Self::CpuSet => "cpuset",
25 Self::Devices => "devices",
26 Self::HugeTlb => "hugetlb",
27 Self::Pids => "pids",
28 Self::PerfEvent => "perf_event",
29 Self::Memory => "memory",
30 Self::Blkio => "blkio",
31 Self::NetworkPriority => "net_prio",
32 Self::NetworkClassifier => "net_cls",
33 Self::Freezer => "freezer",
34 };
35
36 write!(f, "{print}")
37 }
38}
39
40impl AsRef<str> for ControllerType {
41 fn as_ref(&self) -> &str {
42 match *self {
43 Self::Cpu => "cpu",
44 Self::CpuAcct => "cpuacct",
45 Self::CpuSet => "cpuset",
46 Self::Devices => "devices",
47 Self::HugeTlb => "hugetlb",
48 Self::Pids => "pids",
49 Self::PerfEvent => "perf_event",
50 Self::Memory => "memory",
51 Self::Blkio => "blkio",
52 Self::NetworkPriority => "net_prio",
53 Self::NetworkClassifier => "net_cls",
54 Self::Freezer => "freezer",
55 }
56 }
57}
58
59pub const CONTROLLERS: &[ControllerType] = &[
60 ControllerType::Cpu,
61 ControllerType::CpuAcct,
62 ControllerType::CpuSet,
63 ControllerType::Devices,
64 ControllerType::HugeTlb,
65 ControllerType::Memory,
66 ControllerType::Pids,
67 ControllerType::PerfEvent,
68 ControllerType::Blkio,
69 ControllerType::NetworkPriority,
70 ControllerType::NetworkClassifier,
71 ControllerType::Freezer,
72];