zerolaunch_plugin_host/
info.rs1use serde::Serialize;
8use zerolaunch_plugin_api::plugin::{PluginKind, PluginMetadata, PluginMode};
9
10use crate::manager::PluginRuntimeState;
11
12#[derive(Debug, Clone, Serialize)]
14pub struct PluginInfo {
15 #[serde(rename = "pluginId")]
17 pub plugin_id: String,
18 #[serde(rename = "name")]
19 pub name: String,
20 #[serde(rename = "version")]
21 pub version: String,
22 #[serde(rename = "description")]
23 pub description: String,
24 #[serde(rename = "author")]
25 pub author: String,
26 #[serde(rename = "state")]
28 pub state: PluginRuntimeState,
29 #[serde(rename = "enabled")]
31 pub enabled: bool,
32 #[serde(rename = "kind", default)]
34 pub kind: PluginKind,
35 #[serde(rename = "priority")]
36 pub priority: u32,
37 #[serde(rename = "componentIds", default)]
39 pub component_ids: Vec<String>,
40 #[serde(rename = "hotkey", default)]
42 pub hotkey: Option<String>,
43 #[serde(rename = "icon", default)]
45 pub icon: Option<String>,
46 #[serde(rename = "mode", default)]
48 pub mode: PluginMode,
49}
50
51impl PluginInfo {
52 pub fn from_metadata(
57 meta: &PluginMetadata,
58 state: PluginRuntimeState,
59 component_ids: Vec<String>,
60 enabled: bool,
61 ) -> Self {
62 Self {
63 plugin_id: meta.id.clone(),
64 name: meta.name.clone(),
65 version: meta.version.clone(),
66 description: meta.description.clone(),
67 author: meta.author.clone(),
68 state,
69 enabled,
70 kind: meta.kind,
71 priority: meta.priority,
72 component_ids,
73 hotkey: meta.hotkey.clone(),
74 icon: meta.icon.clone(),
75 mode: meta.mode,
76 }
77 }
78}