horizon_plugin_api/
lib.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
30
#[derive(Clone)]
pub struct Plugin {}

#[derive(PartialEq, Eq,Hash)]
pub enum Pluginstate {
    ACTIVE,
    INACTIVE,
    CRASH,
}

#[derive(Clone)]
pub struct LoadedPlugin {
    pub instance: Plugin,
}

pub struct Version {
    pub major: u16,
    pub minor: u16,
    pub hotfix: u16,
}

#[macro_export]
macro_rules! get_plugin {
    ($name:ident, $plugins:expr) => {
        $plugins
            .get(stringify!($name))
            .map(|p| &p.instance as &dyn $name::PluginAPI)
            .expect(&format!("Plugin {} not found", stringify!($name)))
    };
}