Skip to main content

fresh_core/
file_explorer.rs

1use serde::{Deserialize, Serialize};
2use std::path::PathBuf;
3use ts_rs::TS;
4
5/// Decoration metadata for a file explorer entry.
6#[derive(Debug, Clone, Serialize, Deserialize, TS)]
7#[serde(deny_unknown_fields)]
8#[ts(export)]
9pub struct FileExplorerDecoration {
10    /// File path to decorate
11    #[ts(type = "string")]
12    pub path: PathBuf,
13    /// Symbol to display (e.g., "●", "M", "A")
14    pub symbol: String,
15    /// Color as RGB array (rquickjs_serde requires array, not tuple)
16    #[ts(type = "[number, number, number]")]
17    pub color: [u8; 3],
18    /// Priority for display when multiple decorations exist (higher wins)
19    #[serde(default)]
20    pub priority: i32,
21}
22
23#[cfg(feature = "plugins")]
24impl<'js> rquickjs::FromJs<'js> for FileExplorerDecoration {
25    fn from_js(_ctx: &rquickjs::Ctx<'js>, value: rquickjs::Value<'js>) -> rquickjs::Result<Self> {
26        rquickjs_serde::from_value(value).map_err(|e| rquickjs::Error::FromJs {
27            from: "object",
28            to: "FileExplorerDecoration",
29            message: Some(e.to_string()),
30        })
31    }
32}