BlueGit

ict rusty-teams

Files

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

assets.rs

assets.rs 1.9 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!("../../app/assets/symbols/", $name, ".svg")) as &[u8])),*]
8 };
9}
10
11const SYMBOLS: [(&str, &[u8]); 54] = symbols![
12 "bot",
13 "done",
14 "done_all",
15 "keyboard_return",
16 "schedule",
17 "schedule_send",
18 "event",
19 "wb_sunny",
20 "work",
21 "close",
22 "reply",
23 "group",
24 "tag",
25 "image",
26 "check_circle",
27 "error",
28 "notifications",
29 "content_copy",
30 "attach_file",
31 "upload",
32 "download",
33 "folder_open",
34 "refresh",
35 "code",
36 "link",
37 "format_list_bulleted",
38 "format_list_numbered",
39 "format_quote",
40 "mood",
41 "status_dot",
42 "status_dnd",
43 "status_away",
44 "status_ring",
45 "zoom_in",
46 "zoom_out",
47 "rotate_right",
48 "forward",
49 "open_in_new",
50 "chevron_left",
51 "chevron_right",
52 "fullscreen",
53 "spinner_track",
54 "spinner_arc",
55 "shield",
56 "call",
57 "call_missed",
58 "videocam",
59 "fluent_video",
60 "fluent_record",
61 "fluent_record_stop",
62 "fluent_cloud_arrow_up",
63 "fluent_share",
64 "fluent_clock",
65 "fluent_document_text",
66];
67
68pub struct AppAssets;
69
70impl AssetSource for AppAssets {
71 fn load(&self, path: &str) -> Result<Option<Cow<'static, [u8]>>> {
72 if let Some((_, bytes)) = SYMBOLS.iter().find(|(name, _)| *name == path) {
73 return Ok(Some(Cow::Borrowed(bytes)));
74 }
75 gpui_kit::assets::AllAssets.load(path)
76 }
77
78 fn list(&self, path: &str) -> Result<Vec<SharedString>> {
79 let mut names = gpui_kit::assets::AllAssets.list(path)?;
80 names.extend(
81 SYMBOLS
82 .iter()
83 .filter(|(name, _)| name.starts_with(path))
84 .map(|(name, _)| SharedString::from(*name)),
85 );
86 Ok(names)
87 }
88}