#[derive(Plugin)]
{
// Attributes available to this derive:
#[plugin]
}
Expand description
从结构体上的 #[plugin(depends(A, B))] 生成 [plugctx::Plugin] 实现。
dependencies():返回声明类型的TypeId列表(无depends则为空)。build():委托到用户固有方法fn on_build(&self, ctx: &mut Context) -> Result<(), Error>。
§示例
ⓘ
use plugctx_derive::Plugin;
#[derive(Plugin)]
#[plugin(depends(Logger))]
struct MyPlugin;
impl MyPlugin {
fn on_build(&self, ctx: &mut plugctx::Context) -> Result<(), plugctx::Error> {
let _ = ctx.get::<Logger>();
Ok(())
}
}