pub trait Plugin:
Any
+ Send
+ Sync {
// Required methods
fn name(&self) -> &str;
fn on_mail(&self, event: &Event);
// Provided methods
fn deps(&self) -> &[&str] { ... }
fn routes(&self) -> Vec<Cow<'static, str>> { ... }
fn mailbox_cap(&self) -> usize { ... }
fn on_init(&self, _ctx: &PluginContext) { ... }
fn on_start(&self) { ... }
fn on_stop(&self) { ... }
}Required Methods§
Provided Methods§
Sourcefn routes(&self) -> Vec<Cow<'static, str>>
fn routes(&self) -> Vec<Cow<'static, str>>
订阅的 type 集合:广播 type(如业务常量 “eTick.”)、 自身的寻址 type(e_req_type(本名)/e_to_type(本名))。 宿主 start() 装配 forwarder → 邮箱 → on_mail。
Sourcefn mailbox_cap(&self) -> usize
fn mailbox_cap(&self) -> usize
邮箱容量覆写(D5:按插件可小可大,默认 MAILBOX_CAP)。
Sourcefn on_init(&self, _ctx: &PluginContext)
fn on_init(&self, _ctx: &PluginContext)
可选:启动前纯接线(缓存 ctx、读配置)。禁止在此 put/注册 handler(规范)。
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".