Optimised thingy
This commit is contained in:
Generated
+16
@@ -2,6 +2,22 @@
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.99"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b0674a1ddeecb70197781e945de4b3b8ffb61fa939a5597bcf48503737663100"
|
||||
|
||||
[[package]]
|
||||
name = "test-plugin"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"voxa-server",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "voxa-server"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
]
|
||||
|
||||
@@ -4,4 +4,7 @@ version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[dependencies]
|
||||
voxa-server = { path = "../", default-features = false }
|
||||
+2
-19
@@ -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!");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user