assets.rs
1use anyhow::{anyhow, Result};
2use gpui::AssetSource;
3use rust_embed::RustEmbed;
4
5#[derive(RustEmbed)]
6#[folder = "assets"]
7pub struct Assets;
8
9impl AssetSource for Assets {
10 fn load(&self, path: &str) -> Result<std::borrow::Cow<[u8]>> {
11 Self::get(path).ok_or_else(|| anyhow!("could not find asset at path \"{}\"", path))
12 }
13
14 fn list(&self, path: &str) -> Vec<std::borrow::Cow<'static, str>> {
15 Self::iter().filter(|p| p.starts_with(path)).collect()
16 }
17}