1use anyhow::{anyhow, Result};
2use gpui::AssetSource;
3use rust_embed::RustEmbed;
4
5#[derive(RustEmbed)]
6#[folder = "../../assets"]
7#[include = "fonts/**/*"]
8#[include = "icons/**/*"]
9#[include = "themes/**/*"]
10#[include = "sounds/**/*"]
11#[include = "*.md"]
12#[exclude = "*.DS_Store"]
13pub struct Assets;
14
15impl AssetSource for Assets {
16 fn load(&self, path: &str) -> Result<std::borrow::Cow<[u8]>> {
17 Self::get(path)
18 .map(|f| f.data)
19 .ok_or_else(|| anyhow!("could not find asset at path \"{}\"", path))
20 }
21
22 fn list(&self, path: &str) -> Vec<std::borrow::Cow<'static, str>> {
23 Self::iter().filter(|p| p.starts_with(path)).collect()
24 }
25}