Skip to main content

Plugin

Trait Plugin 

Source
pub trait Plugin: Send + Sync {
    // Required methods
    fn info(&self) -> PluginInfo;
    fn as_any(&self) -> &dyn Any;
    fn as_any_mut(&mut self) -> &mut dyn Any;

    // Provided methods
    fn status(&self) -> PluginStatus { ... }
    fn init<'life0, 'async_trait>(
        &'life0 mut self,
        _config: Value,
    ) -> Pin<Box<dyn Future<Output = PluginResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn ready<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = PluginResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn destroy<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = PluginResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn invoke<'life0, 'life1, 'async_trait>(
        &'life0 self,
        method: &'life1 str,
        _params: Value,
    ) -> Pin<Box<dyn Future<Output = PluginResult<Value>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

插件 trait

Required Methods§

Source

fn info(&self) -> PluginInfo

获取插件信息

Source

fn as_any(&self) -> &dyn Any

转换为 Any(用于类型转换)

Source

fn as_any_mut(&mut self) -> &mut dyn Any

Provided Methods§

Source

fn status(&self) -> PluginStatus

获取插件状态

Source

fn init<'life0, 'async_trait>( &'life0 mut self, _config: Value, ) -> Pin<Box<dyn Future<Output = PluginResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

插件初始化

Source

fn ready<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = PluginResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

插件就绪

Source

fn destroy<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = PluginResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

插件销毁

Source

fn invoke<'life0, 'life1, 'async_trait>( &'life0 self, method: &'life1 str, _params: Value, ) -> Pin<Box<dyn Future<Output = PluginResult<Value>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

调用插件方法

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§