mirror of
https://github.com/zed-industries/zed.git
synced 2024-10-27 08:50:29 +00:00
c065f283aa
Also, move assets folder to the top-level. Co-authored-by: Keith Simmons <keith@zed.dev>
21 lines
556 B
Rust
21 lines
556 B
Rust
use anyhow::{anyhow, Result};
|
|
use gpui::AssetSource;
|
|
use rust_embed::RustEmbed;
|
|
|
|
#[derive(RustEmbed)]
|
|
#[folder = "../../assets"]
|
|
#[exclude = "*.DS_Store"]
|
|
pub struct Assets;
|
|
|
|
impl AssetSource for Assets {
|
|
fn load(&self, path: &str) -> Result<std::borrow::Cow<[u8]>> {
|
|
Self::get(path)
|
|
.map(|f| f.data)
|
|
.ok_or_else(|| anyhow!("could not find asset at path \"{}\"", path))
|
|
}
|
|
|
|
fn list(&self, path: &str) -> Vec<std::borrow::Cow<'static, str>> {
|
|
Self::iter().filter(|p| p.starts_with(path)).collect()
|
|
}
|
|
}
|