diff --git a/plugins/hotload_toto1/src/lib.rs b/plugins/hotload_toto1/src/lib.rs index 080c089..eebfb2c 100644 --- a/plugins/hotload_toto1/src/lib.rs +++ b/plugins/hotload_toto1/src/lib.rs @@ -2,3 +2,8 @@ pub extern fn version() -> String { "0.2.0".to_string() } + +#[no_mangle] +pub extern fn name() -> String { + "test name".to_string() +} diff --git a/src/main.rs b/src/main.rs index e529e38..555d51a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,7 @@ mod plugin_manager; fn main() { - plugin_manager::PluginManager::new(); + let plugin_manager = plugin_manager::PluginManager::new(); + + println!("Plugins number : {}", plugin_manager.plugins.len()); } diff --git a/src/plugin_manager.rs b/src/plugin_manager.rs index 2f7b821..3b47df2 100644 --- a/src/plugin_manager.rs +++ b/src/plugin_manager.rs @@ -1,10 +1,11 @@ +use glob::glob; use std::env::current_exe; use std::path::PathBuf; -use glob::glob; #[derive(Debug, Clone)] pub struct Plugin { - pub version: String + pub version: String, + pub name: String, } pub struct PluginManager { @@ -12,7 +13,7 @@ pub struct PluginManager { } impl PluginManager { - pub fn new() { + pub fn new() -> PluginManager { println!("Loading librairies..."); let mut plugins = Vec::new(); let current_path = current_exe().unwrap(); @@ -23,15 +24,21 @@ impl PluginManager { println!("Loaded plugin {:?}", plugin); plugins.push(plugin); } + + PluginManager { plugins } } fn load_library(lib_file: PathBuf) -> Plugin { println!("Loading library {:?}", lib_file); unsafe { let lib = libloading::Library::new(lib_file).unwrap(); - let version_func : libloading::Symbol String> = lib.get(b"version").unwrap(); + let version_func: libloading::Symbol String> = + lib.get(b"version").unwrap(); + let name_func: libloading::Symbol String> = + lib.get(b"name").unwrap(); Plugin { - version: version_func() + version: version_func(), + name: name_func(), } } }