1use std::path::Path;
2use std::fs;
3use std::sync::Arc;
4use crate::{Plugin, PluginInfo, Result};
5
6pub struct PluginLoader;
8
9impl PluginLoader {
10 pub fn new() -> Self {
11 Self
12 }
13
14 #[cfg(not(target_arch = "wasm32"))]
16 pub fn load_from_file<P: AsRef<Path>>(&self, path: P) -> Result<Arc<dyn Plugin>> {
17 Err(oxidite_core::Error::InternalServerError(
20 "Plugin loading from file not implemented in this version".to_string()
21 ))
22 }
23
24 pub fn scan_directory<P: AsRef<Path>>(&self, path: P) -> Result<Vec<std::path::PathBuf>> {
26 let mut plugins = Vec::new();
27
28 Ok(plugins)
31 }
32
33 pub async fn load_from_directory<P: AsRef<Path>>(&self, path: P) -> Result<Vec<Arc<dyn Plugin>>> {
35 let mut plugins = Vec::new();
36
37 println!("Scanning for plugins in: {:?}", path.as_ref());
39
40 Ok(plugins)
41 }
42}
43
44#[cfg(test)]
45mod tests {
46 use super::*;
47
48 struct TestPlugin;
50
51 #[async_trait::async_trait]
52 impl Plugin for TestPlugin {
53 fn info(&self) -> PluginInfo {
54 PluginInfo::new(
55 "test-plugin",
56 "Test Plugin",
57 "1.0.0",
58 "A test plugin for Oxidite",
59 "Test Author"
60 )
61 }
62 }
63
64 #[test]
65 fn test_plugin_info() {
66 let plugin = TestPlugin;
67 let info = plugin.info();
68
69 assert_eq!(info.id, "test-plugin");
70 assert_eq!(info.name, "Test Plugin");
71 assert_eq!(info.version, "1.0.0");
72 }
73}