br_addon/
addon.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use crate::module::Module;
use std::any::type_name;

/// 插件接口
pub trait Addon {
    /// 插件名称
    fn _name(&self) -> String {
        type_name::<Self>()
            .rsplit("::")
            .next()
            .unwrap()
            .to_lowercase()
    }
    /// 插件标题
    fn title(&self) -> &'static str;
    /// 插件图标
    fn icon(&self) -> &'static str {
        ""
    }
    /// 功能描述
    fn description(&self) -> &'static str {
        ""
    }
    fn sort(&self) -> usize {
        99
    }
    /// 模型分流
    fn module(&mut self, name: &str) -> Result<Box<dyn Module>, String>;
}