BlueGit

ict rusty-teams

Files

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

assets.rs

b2f76237 History
assets.rs 1.1 KiB Download Raw
1use std::borrow::Cow;
2
3use gpui_kit::{AssetSource, Result, SharedString};
4
5const SYMBOLS: [(&str, &[u8]); 4] = [
6 ("symbols/done.svg", include_bytes!("../assets/symbols/done.svg")),
7 ("symbols/done_all.svg", include_bytes!("../assets/symbols/done_all.svg")),
8 ("symbols/keyboard_return.svg", include_bytes!("../assets/symbols/keyboard_return.svg")),
9 ("symbols/schedule.svg", include_bytes!("../assets/symbols/schedule.svg")),
10];
11
12pub struct AppAssets;
13
14impl AssetSource for AppAssets {
15 fn load(&self, path: &str) -> Result<Option<Cow<'static, [u8]>>> {
16 if let Some((_, bytes)) = SYMBOLS.iter().find(|(name, _)| *name == path) {
17 return Ok(Some(Cow::Borrowed(bytes)));
18 }
19 gpui_kit::assets::AllAssets.load(path)
20 }
21
22 fn list(&self, path: &str) -> Result<Vec<SharedString>> {
23 let mut names = gpui_kit::assets::AllAssets.list(path)?;
24 names.extend(
25 SYMBOLS
26 .iter()
27 .filter(|(name, _)| name.starts_with(path))
28 .map(|(name, _)| SharedString::from(*name)),
29 );
30 Ok(names)
31 }
32}