Skip to main content

MainEngine

Struct MainEngine 

Source
pub struct MainEngine { /* private fields */ }

Implementations§

Source§

impl MainEngine

Source

pub fn new(event: Option<Arc<EventEngine>>) -> Self

注入式创建:Some(bus) 复用外部引擎;None 自建(start() 时拉起)。

Source

pub fn event_engine(&self) -> &Arc<EventEngine> ⓘ

宿主级引擎句柄(测试/装配工具可用;插件不可见——ctx 不暴露)。

Source

pub fn add_plugin( &self, plugin: Arc<impl Plugin + 'static>, ) -> Result<(), PluginError>

统一格式注册(D2:名/重名/同名自依赖;add 期【不校验 deps 存在性】—— 新 D1 注册自由,悬空 deps 由 start 期把关)。

运行期动态 add(0.2.0):start 之后仍可随时注入新插件——登记 → 织入 能力索引 → 立即走 launch_one 装配上线 → 记入 started_order(close 反序覆盖); 并广播 ePlugUp / ePlugUp.<名>,迟绑定依赖方据此自主发现。

Source

pub fn get_state(&self, name: &str) -> Option<PluginState>

状态查询。

Source

pub fn get_plugin(&self, name: &str) -> Option<PluginInfo>

信息快照。

Source

pub fn get_typed<T: Plugin + 'static>(&self, name: &str) -> Option<Arc<T>>

类型安全获取(get_typed):同一分配的 Arc downcast。

Source

pub fn plugin_arc(&self, name: &str) -> Option<Arc<dyn Plugin>>

dyn 取壳(0.5.3 新增,additive):按注册名取回 Arc<dyn Plugin> 本体。

存在理由:装配侧把插件包进壳里(如 ek-station 的 DynPlugin)时,注册表的 downcast 底座是壳类型,get_typed::<真插件> 必然落空 —— 本口把 dyn 本体交回, 界面侧经 Plugin::as_any 自行 downcast(壳侧需转发 as_any)。 与 get_typed 互补,不改任何既有行为。

Source

pub fn plugin_names(&self) -> Vec<String>

注册名列表(注册序)。

Source

pub fn mail_stats(&self, name: &str) -> Option<MailStats>

运行统计(软顶丢弃/panic/当前深度/峰值/软顶)。未注册 → None。

Source

pub fn start(&self) -> Result<(), PluginError>

启动全部插件:总线 start → deps 拓扑序逐个装配 (on_init → 建邮箱 → spawn worker → state=Running → 注册 forwarder → on_start → 广播 ePlugUp)。 依赖环/悬空 deps → DepCycle/UnknownDep;重复 start 幂等 Ok;已 close → Stopped。

Source

pub fn close(&self, timeout: Duration)

全局闭停:逆 start 序逐插件五步;然后清插件表。总线留给调用方(close_all 停总线)。

Source

pub fn close_all(&self, timeout: Duration)

close + 停总线(终态)。

Source

pub fn remove_plugin(&self, name: &str) -> Result<(), PluginError>

移除单个插件:Running 者执行五步(UNKNOWN 表项报错);仍被其他插件 deps 引用 时 stderr 警告(定稿 policy:允许移除 + 警告;依赖方后续 ask 走预检/断连失败)。

0.2.0:同步修剪能力索引(F3:防幽灵提供方)+ 作废缓存,并发 ePlugDown(固定版,PlugNotice)+ ePlugDown.<名>(后缀版,版本串)。 注:close()(宿主整体下架)不发逐插件 ePlugDown(审核 F7:避免拆除期事件风暴)。

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.