use async_trait::async_trait; use serde_json::Value; use crate::FileTree; #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] pub struct SortOption { pub key: String, pub label: String, } #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] pub struct FilterOption { pub key: String, pub label: String, } #[async_trait] pub trait DisplayMode: Send + Sync { fn name(&self) -> &'static str; fn render(&self, tree: &FileTree) -> Value; fn sort_options(&self) -> Vec; fn filter_options(&self) -> Vec; } pub fn get_mode(name: &str) -> Option> { match name { "tree" => Some(Box::new(crate::modes::tree::TreeMode)), "list" => Some(Box::new(crate::modes::list::ListMode)), "grid_sm" => Some(Box::new(crate::modes::grid_sm::GridSmMode)), "grid_lg" => Some(Box::new(crate::modes::grid_lg::GridLgMode)), _ => None, } } pub fn list_modes() -> Vec> { vec![ Box::new(crate::modes::list::ListMode), Box::new(crate::modes::tree::TreeMode), Box::new(crate::modes::grid_sm::GridSmMode), Box::new(crate::modes::grid_lg::GridLgMode), ] }