mangofetch_core/core/manager/
plugin_host.rs1use mangofetch_plugin_sdk::{PluginHost, ProxyConfig};
2use std::path::PathBuf;
3
4pub struct CorePluginHost;
5
6impl PluginHost for CorePluginHost {
7 fn emit_event(&self, name: &str, payload: serde_json::Value) -> anyhow::Result<()> {
8 tracing::info!("[plugin-event] {}: {}", name, payload);
9 Ok(())
10 }
11
12 fn show_toast(&self, toast_type: &str, message: &str) -> anyhow::Result<()> {
13 tracing::info!("[plugin-toast] [{}]: {}", toast_type, message);
14 Ok(())
15 }
16
17 fn plugin_data_dir(&self, plugin_id: &str) -> PathBuf {
18 crate::core::paths::app_data_dir()
19 .unwrap_or_else(|| PathBuf::from("."))
20 .join("plugins")
21 .join(plugin_id)
22 }
23
24 fn plugin_frontend_dir(&self, plugin_id: &str) -> PathBuf {
25 crate::core::paths::app_data_dir()
26 .unwrap_or_else(|| PathBuf::from("."))
27 .join("plugins")
28 .join(plugin_id)
29 .join("frontend")
30 }
31
32 fn get_settings(&self, _plugin_id: &str) -> serde_json::Value {
33 serde_json::Value::Null
34 }
35
36 fn save_settings(&self, _plugin_id: &str, _settings: serde_json::Value) -> anyhow::Result<()> {
37 Ok(())
38 }
39
40 fn proxy_config(&self) -> Option<ProxyConfig> {
41 None
42 }
43
44 fn tool_path(&self, _tool: &str) -> Option<PathBuf> {
45 None
46 }
47
48 fn default_output_dir(&self) -> PathBuf {
49 dirs::download_dir().unwrap_or_else(|| PathBuf::from("."))
50 }
51}