Skip to main content

kernel/
host_toolkit.rs

1// Copyright 2026 Mark AB (markik)
2// SPDX-License-Identifier: MIT OR Apache-2.0
3
4/// GUI toolkit families that should receive fresh Graphshell host adapters.
5#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
6pub enum HostToolkit {
7    Iced,
8    Gpui,
9    HtmlCss,
10    Makepad,
11    Egui,
12}
13
14pub const NEW_HOST_TOOLKIT_ORDER: [HostToolkit; 5] = [
15    HostToolkit::Iced,
16    HostToolkit::Gpui,
17    HostToolkit::HtmlCss,
18    HostToolkit::Makepad,
19    HostToolkit::Egui,
20];
21
22pub fn preferred_host_toolkits() -> &'static [HostToolkit] {
23    &NEW_HOST_TOOLKIT_ORDER
24}
25
26impl HostToolkit {
27    pub const fn id(self) -> &'static str {
28        match self {
29            Self::Iced => "iced",
30            Self::Gpui => "gpui",
31            Self::HtmlCss => "html-css",
32            Self::Makepad => "makepad",
33            Self::Egui => "egui",
34        }
35    }
36
37    pub const fn crate_name(self) -> &'static str {
38        match self {
39            Self::Iced => "graphshell-host-iced",
40            Self::Gpui => "graphshell-host-gpui",
41            Self::HtmlCss => "graphshell-host-html-css",
42            Self::Makepad => "graphshell-host-makepad",
43            Self::Egui => "graphshell-host-egui",
44        }
45    }
46}
47
48#[cfg(test)]
49mod tests {
50    use super::*;
51
52    #[test]
53    fn preferred_host_order_keeps_egui_last() {
54        assert_eq!(
55            preferred_host_toolkits(),
56            [
57                HostToolkit::Iced,
58                HostToolkit::Gpui,
59                HostToolkit::HtmlCss,
60                HostToolkit::Makepad,
61                HostToolkit::Egui,
62            ]
63        );
64    }
65
66    #[test]
67    fn toolkit_ids_and_crate_names_are_stable() {
68        let pairs: Vec<_> = preferred_host_toolkits()
69            .iter()
70            .map(|toolkit| (toolkit.id(), toolkit.crate_name()))
71            .collect();
72
73        assert_eq!(
74            pairs,
75            [
76                ("iced", "graphshell-host-iced"),
77                ("gpui", "graphshell-host-gpui"),
78                ("html-css", "graphshell-host-html-css"),
79                ("makepad", "graphshell-host-makepad"),
80                ("egui", "graphshell-host-egui"),
81            ]
82        );
83    }
84}