zerolaunch_plugin_api/plugin/
plugin_trait.rs1use crate::config::configurable::Configurable;
2use crate::host::plugin_handle::PluginHandle;
3use crate::plugin::types::{
4 PanelInteraction, PluginContext, PluginError, PluginMetadata, Query, QueryResponse,
5};
6use async_trait::async_trait;
7use std::sync::Arc;
8
9#[async_trait]
13pub trait Plugin: Configurable {
14 fn metadata(&self) -> &PluginMetadata;
15
16 async fn init(
22 &self,
23 ctx: &PluginContext,
24 handle: Option<Arc<PluginHandle>>,
25 ) -> Result<(), PluginError>;
26
27 async fn query(&self, ctx: &PluginContext, query: &Query)
28 -> Result<QueryResponse, PluginError>;
29
30 async fn execute_action(
38 &self,
39 ctx: &PluginContext,
40 action_id: &str,
41 payload: serde_json::Value,
42 ) -> Result<(), PluginError>;
43
44 fn interaction_policy(&self) -> PanelInteraction {
48 PanelInteraction::default()
49 }
50}