horizon_plugin_api/
lib.rs1#[derive(Clone, Debug)]
2pub struct Plugin {}
3
4#[derive(PartialEq, Eq, Hash, Clone)]
5pub enum Pluginstate {
6 ACTIVE,
7 INACTIVE,
8 CRASH,
9}
10
11#[derive(Clone, Debug)]
12pub struct LoadedPlugin {
13 pub instance: Plugin,
14}
15
16pub struct Version {
17 pub major: u16,
18 pub minor: u16,
19 pub hotfix: u16,
20}
21
22#[macro_export]
23macro_rules! get_plugin {
24 ($name:ident, $plugins:expr) => {
25 $plugins
26 .get(stringify!($name))
27 .map(|p| &p.instance as &dyn $name::PluginAPI)
28 .expect(&format!("Plugin {} not found", stringify!($name)))
29 };
30}
31
32#[macro_export]
33macro_rules! get_type_from_plugin {
34 ($name:ident, $plugins:expr, $api:ty) => {
35 $plugins
36 .get(stringify!($name))
37 .map(|p| &p.instance as $name::&$api)
38 .expect(&format!("Plugin {} not found", stringify!($name)))
39 };
40}