Nothing to see here, move along
1use crate::color::{BasicColor, Color};
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq)]
4pub enum DomainGroup {
5 Core,
6 Platform,
7 Execution,
8 Drivers,
9 Filesystem,
10 Network,
11 Shell,
12}
13
14impl DomainGroup {
15 pub const fn label_color(self) -> Color {
16 match self {
17 Self::Core => Color::hex(0x6E8FA8),
18 Self::Platform => Color::hex(0x5BA8A0),
19 Self::Execution => Color::hex(0x8A7EB8),
20 Self::Drivers => Color::hex(0x4ABFCF),
21 Self::Filesystem => Color::hex(0x7BAE7F),
22 Self::Network => Color::hex(0xC4A24E),
23 Self::Shell => Color::hex(0xA0AAB4),
24 }
25 }
26
27 pub const fn label_color_basic(self) -> BasicColor {
28 match self {
29 Self::Core => BasicColor::Blue,
30 Self::Platform => BasicColor::Cyan,
31 Self::Execution => BasicColor::Magenta,
32 Self::Drivers => BasicColor::BrightCyan,
33 Self::Filesystem => BasicColor::Green,
34 Self::Network => BasicColor::Yellow,
35 Self::Shell => BasicColor::White,
36 }
37 }
38}
39
40const DOMAIN_TABLE: &[(&str, DomainGroup)] = &[
41 ("mem", DomainGroup::Core),
42 ("gdt", DomainGroup::Core),
43 ("idt", DomainGroup::Core),
44 ("phys", DomainGroup::Core),
45 ("virt", DomainGroup::Core),
46 ("kern", DomainGroup::Core),
47 ("boot", DomainGroup::Core),
48 ("sys", DomainGroup::Core),
49 ("apic", DomainGroup::Platform),
50 ("pci", DomainGroup::Platform),
51 ("acpi", DomainGroup::Platform),
52 ("ioapic", DomainGroup::Platform),
53 ("cpu", DomainGroup::Platform),
54 ("iommu", DomainGroup::Platform),
55 ("sched", DomainGroup::Execution),
56 ("proc", DomainGroup::Execution),
57 ("cap", DomainGroup::Execution),
58 ("wcet", DomainGroup::Execution),
59 ("ipc", DomainGroup::Execution),
60 ("loader", DomainGroup::Execution),
61 ("nvme", DomainGroup::Drivers),
62 ("serial", DomainGroup::Drivers),
63 ("fbcon", DomainGroup::Drivers),
64 ("ps2", DomainGroup::Drivers),
65 ("virtio", DomainGroup::Drivers),
66 ("fb", DomainGroup::Drivers),
67 ("vfs", DomainGroup::Filesystem),
68 ("ramfs", DomainGroup::Filesystem),
69 ("lancerfs", DomainGroup::Filesystem),
70 ("net", DomainGroup::Network),
71 ("arp", DomainGroup::Network),
72 ("dns", DomainGroup::Network),
73 ("udp", DomainGroup::Network),
74 ("init", DomainGroup::Shell),
75 ("rsh", DomainGroup::Shell),
76 ("fstest", DomainGroup::Shell),
77 ("test", DomainGroup::Shell),
78];
79
80pub fn classify(domain: &str) -> DomainGroup {
81 let bytes = domain.as_bytes();
82 DOMAIN_TABLE
83 .iter()
84 .fold(DomainGroup::Shell, |result, &(name, group)| {
85 match name.as_bytes() == bytes {
86 true => group,
87 false => result,
88 }
89 })
90}