Skip to main content

libcgroups/v2/
controller_type.rs

1use std::fmt::Display;
2
3#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
4pub enum ControllerType {
5    Cpu,
6    CpuSet,
7    Io,
8    Memory,
9    HugeTlb,
10    Pids,
11}
12
13impl Display for ControllerType {
14    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15        let print = match self {
16            Self::Cpu => "cpu",
17            Self::CpuSet => "cpuset",
18            Self::Io => "io",
19            Self::Memory => "memory",
20            Self::HugeTlb => "hugetlb",
21            Self::Pids => "pids",
22        };
23
24        write!(f, "{print}")
25    }
26}
27
28pub const CONTROLLER_TYPES: &[ControllerType] = &[
29    ControllerType::Cpu,
30    ControllerType::CpuSet,
31    ControllerType::HugeTlb,
32    ControllerType::Io,
33    ControllerType::Memory,
34    ControllerType::Pids,
35];
36
37#[derive(Clone, Copy, PartialEq, Eq, Hash)]
38pub enum PseudoControllerType {
39    Devices,
40    Freezer,
41    Unified,
42}
43
44impl Display for PseudoControllerType {
45    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
46        let print = match self {
47            Self::Devices => "devices",
48            Self::Freezer => "freezer",
49            Self::Unified => "unified",
50        };
51
52        write!(f, "{print}")
53    }
54}
55
56pub const PSEUDO_CONTROLLER_TYPES: &[PseudoControllerType] = &[
57    PseudoControllerType::Devices,
58    PseudoControllerType::Freezer,
59    PseudoControllerType::Unified,
60];