Optimised thingy

This commit is contained in:
2025-08-29 01:15:40 +02:00
parent 8cffa11669
commit 68bf864a52
6 changed files with 57 additions and 43 deletions
+2 -19
View File
@@ -1,26 +1,9 @@
pub trait Plugin {
fn init(&mut self);
}
macro_rules! export_plugin {
($plugin_type:ty) => {
static PLUGIN: std::sync::Mutex<Option<$plugin_type>> = std::sync::Mutex::new(None);
#[unsafe(no_mangle)]
pub extern "C" fn init() {
let mut plugin = PLUGIN.lock().unwrap();
*plugin = Some(<$plugin_type>::default());
if let Some(plugin) = plugin.as_mut() {
plugin.init();
}
}
};
}
use voxa_server::{PluginApi, export_plugin};
#[derive(Default)]
pub struct MyPlugin;
impl Plugin for MyPlugin {
impl PluginApi for MyPlugin {
fn init(&mut self) {
println!("MyPlugin initialized!");
}