gpui_kit_assets/
native_assets.rs1use anyhow::anyhow;
2use gpui::{AssetSource, Result, SharedString};
3use std::borrow::Cow;
4
5#[derive(rust_embed::RustEmbed)]
7#[folder = "assets"]
8#[include = "icons/**/*.svg"]
9pub struct Assets;
10
11impl Assets {
12 pub fn new(_endpoint: impl Into<SharedString>) -> Self {
14 Self
15 }
16}
17
18impl AssetSource for Assets {
19 fn load(&self, path: &str) -> Result<Option<Cow<'static, [u8]>>> {
20 if path.is_empty() {
21 return Ok(None);
22 }
23
24 Self::get(path)
25 .map(|f| Some(f.data))
26 .ok_or_else(|| anyhow!("could not find asset at path \"{}\"", path))
27 }
28
29 fn list(&self, path: &str) -> Result<Vec<SharedString>> {
30 Ok(Self::iter()
31 .filter_map(|p| p.starts_with(path).then(|| p.into()))
32 .collect())
33 }
34}