Removed loader

This commit is contained in:
2025-12-11 21:09:06 +01:00
parent df2ac3fe4d
commit f49e5aa108
4 changed files with 0 additions and 50 deletions
-2
View File
@@ -7,7 +7,6 @@ edition = "2024"
anyhow = "1.0.99" anyhow = "1.0.99"
base64 = "0.22.1" base64 = "0.22.1"
chrono = "0.4.42" chrono = "0.4.42"
libloading = { version = "0.8.8", optional = true }
once_cell = "1.21.3" once_cell = "1.21.3"
rand = "0.9.2" rand = "0.9.2"
rusqlite = "0.37.0" rusqlite = "0.37.0"
@@ -18,4 +17,3 @@ ureq = "3.1.2"
[features] [features]
default = [] default = []
loader = ["libloading"]
-5
View File
@@ -63,11 +63,6 @@ impl Server {
pub fn run(self: &Arc<Self>) -> crate::Result<()> { pub fn run(self: &Arc<Self>) -> crate::Result<()> {
// Load plugins // Load plugins
#[cfg(feature = "loader")]
utils::loader::load_plugins(
&mut *self.plugins.lock().unwrap(),
&self.root.join("./plugins"),
)?;
// Initialize plugins // Initialize plugins
-41
View File
@@ -1,41 +0,0 @@
use std::path::Path;
use libloading::{Library, Symbol};
use crate::{logger, utils::plugin::DynPlugin, utils::vfs};
logger! {
const LOGGER "Loader"
}
pub fn load_plugin(path: &Path) -> anyhow::Result<DynPlugin> {
unsafe {
LOGGER.info(format!("Loading plugin: {:?}", path));
let lib = Library::new(path)?;
let func: Symbol<extern "C" fn() -> DynPlugin> = lib.get(b"load_plugin").unwrap();
Ok(func())
}
}
pub fn load_plugins(arr: &mut Vec<DynPlugin>, path: &Path) -> crate::Result<()> {
LOGGER.info("Loading plugins");
vfs::dir(path)?;
if path.is_dir() {
for entry in std::fs::read_dir(path)? {
let entry = entry?;
let path = entry.path();
if path.extension().and_then(|s| s.to_str()) == Some("dylib") {
match load_plugin(&path) {
Ok(plugin) => {
arr.push(plugin);
}
Err(e) => LOGGER.error(format!("Failed to load plugin {:?}: {}", path, e)),
}
}
}
} else {
LOGGER.error(format!("{:?} is not a directory", path));
}
Ok(())
}
-2
View File
@@ -1,7 +1,5 @@
pub mod auth; pub mod auth;
pub mod client; pub mod client;
pub mod database; pub mod database;
#[cfg(feature = "loader")]
pub mod loader;
pub mod logger; pub mod logger;
pub mod vfs; pub mod vfs;