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