| 1 | use std::borrow::Cow; |
| 2 | |
| 3 | use gpui_kit::{AssetSource, Result, SharedString}; |
| 4 | |
| 5 | const SYMBOLS: [(&str, &[u8]); 3] = [ |
| 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 | ]; |
| 10 | |
| 11 | pub struct AppAssets; |
| 12 | |
| 13 | impl AssetSource for AppAssets { |
| 14 | fn load(&self, path: &str) -> Result<Option<Cow<'static, [u8]>>> { |
| 15 | if let Some((_, bytes)) = SYMBOLS.iter().find(|(name, _)| *name == path) { |
| 16 | return Ok(Some(Cow::Borrowed(bytes))); |
| 17 | } |
| 18 | gpui_kit::assets::AllAssets.load(path) |
| 19 | } |
| 20 | |
| 21 | fn list(&self, path: &str) -> Result<Vec<SharedString>> { |
| 22 | let mut names = gpui_kit::assets::AllAssets.list(path)?; |
| 23 | names.extend( |
| 24 | SYMBOLS |
| 25 | .iter() |
| 26 | .filter(|(name, _)| name.starts_with(path)) |
| 27 | .map(|(name, _)| SharedString::from(*name)), |
| 28 | ); |
| 29 | Ok(names) |
| 30 | } |
| 31 | } |