Files
creddy/src/assets.rs
T
2026-11-22 06:17:04 -05:00

28 lines
843 B
Rust

use std::borrow::Cow;
use gpui_kit::assets::{Assets, icon_assets};
use gpui_kit::{AssetSource, Result, SharedString};
// gpui-kit only embeds the icons its own components use, so anything else has to be listed here
icon_assets!(CreddyIcons, [Key, LogOut, Pencil, ShieldCheck, Trash]);
/// Our extra icons, falling back to gpui-kit's defaults.
pub struct CreddyAssets;
impl AssetSource for CreddyAssets {
fn load(&self, path: &str) -> Result<Option<Cow<'static, [u8]>>> {
match CreddyIcons.load(path)? {
Some(bytes) => Ok(Some(bytes)),
None => Assets.load(path),
}
}
fn list(&self, path: &str) -> Result<Vec<SharedString>> {
let mut paths = Assets.list(path)?;
paths.extend(CreddyIcons.list(path)?);
paths.sort();
paths.dedup();
Ok(paths)
}
}