BlueGit

ict rusty-teams

Files

rusty-teams / crates / app / src / assets.rs

assets.rs

assets.rs 1.6 KiB Download Raw
1use std::borrow::Cow;
2
3use gpui_kit::{AssetSource, Result, SharedString};
4
5macro_rules! symbols {
6 ($($name:literal),* $(,)?) => {
7 [$((concat!("symbols/", $name, ".svg"), include_bytes!(concat!("../assets/symbols/", $name, ".svg")) as &[u8])),*]
8 };
9}
10
11const SYMBOLS: [(&str, &[u8]); 40] = symbols![
12 "done",
13 "done_all",
14 "keyboard_return",
15 "schedule",
16 "schedule_send",
17 "event",
18 "wb_sunny",
19 "work",
20 "close",
21 "reply",
22 "group",
23 "tag",
24 "image",
25 "check_circle",
26 "error",
27 "notifications",
28 "content_copy",
29 "attach_file",
30 "upload",
31 "download",
32 "folder_open",
33 "refresh",
34 "code",
35 "link",
36 "format_list_bulleted",
37 "format_list_numbered",
38 "format_quote",
39 "mood",
40 "status_dot",
41 "status_dnd",
42 "status_away",
43 "status_ring",
44 "zoom_in",
45 "zoom_out",
46 "rotate_right",
47 "forward",
48 "open_in_new",
49 "chevron_left",
50 "chevron_right",
51 "fullscreen",
52];
53
54pub struct AppAssets;
55
56impl AssetSource for AppAssets {
57 fn load(&self, path: &str) -> Result<Option<Cow<'static, [u8]>>> {
58 if let Some((_, bytes)) = SYMBOLS.iter().find(|(name, _)| *name == path) {
59 return Ok(Some(Cow::Borrowed(bytes)));
60 }
61 gpui_kit::assets::AllAssets.load(path)
62 }
63
64 fn list(&self, path: &str) -> Result<Vec<SharedString>> {
65 let mut names = gpui_kit::assets::AllAssets.list(path)?;
66 names.extend(
67 SYMBOLS
68 .iter()
69 .filter(|(name, _)| name.starts_with(path))
70 .map(|(name, _)| SharedString::from(*name)),
71 );
72 Ok(names)
73 }
74}