Skip to main content

declare_plugin

Macro declare_plugin 

Source
macro_rules! declare_plugin {
    ($plugin_type:ty, $name:expr, $version:expr) => { ... };
}
Expand description

插件创建宏(供插件开发者使用)

§示例

use sh_layer4::plugin_loader::{Plugin, PluginContext};
use sh_layer4::declare_plugin;

struct MyPlugin;

#[async_trait::async_trait]
impl Plugin for MyPlugin {
    fn name(&self) -> &str { "my_plugin" }
    fn version(&self) -> &str { "0.1.0" }
    async fn initialize(&self, _ctx: &PluginContext) -> anyhow::Result<()> { Ok(()) }
    async fn execute(&self, input: &serde_json::Value) -> anyhow::Result<serde_json::Value> {
        Ok(input.clone())
    }
}

declare_plugin!(MyPlugin, "my_plugin", "0.1.0");