Files
ShowenV2/plugins/example-plugin
XiuChengWu 47d6b06ced chore: upgrade Rust edition 2018 2021
- Cargo.toml: edition 2021
- plugin-sdk/Cargo.toml: edition 2021
- plugins/example-plugin/Cargo.toml: edition 2021

Rust 2021 edition 带来更好的闭包捕获规则、IntoIterator for arrays 等改进。
2026-03-31 23:21:57 +08:00
..

Example Plugin — 示例动态插件

演示如何使用 showen-plugin-sdk 编写动态插件,并提供可直接打包到 plugin_store/manifest.json 模板。

功能

  • 展示消息路由、配置解析、后台任务、自测以及请求/响应模式
  • 展示 ShowenPlugin trait 的完整实现
  • 编译为 cdylib.so 文件)

编译

cd plugins/example-plugin
cargo build --release

产物: target/release/libshowen_example_plugin.so

安装

.somanifest.json 放入 plugin_store/example-plugin/<version>/ 目录即可被主程序动态加载。

文件

文件 说明
src/lib.rs 插件实现,使用 export_plugin! 宏导出
Cargo.toml crate 配置,类型为 cdylib
manifest.json 动态加载所需的完整清单模板