Removed plugin structure

This commit is contained in:
2025-12-11 21:05:36 +01:00
parent ec91e971c0
commit 5d8a93ce84
4 changed files with 6 additions and 44 deletions
-10
View File
@@ -1,13 +1,3 @@
#[macro_export]
macro_rules! export_plugin {
($p:expr) => {
#[unsafe(no_mangle)]
pub extern "C" fn load_plugin() -> $crate::utils::plugin::DynPlugin {
$p
}
};
}
#[macro_export]
macro_rules! logger {
(const $i:ident $name:expr) => {
+6 -11
View File
@@ -7,7 +7,7 @@ use std::{
use crate::{
logger, types,
utils::{self, client::Client, plugin::DynPlugin},
utils::{self, client::Client},
};
#[derive(serde::Serialize, serde::Deserialize)]
@@ -23,7 +23,6 @@ pub struct ServerConfig {
pub struct Server {
pub root: PathBuf,
pub config: ServerConfig,
pub plugins: Mutex<Vec<DynPlugin>>,
pub clients: Mutex<HashSet<Client>>,
pub db: utils::database::Database,
}
@@ -56,7 +55,6 @@ impl Server {
pub fn new_config(root: &Path, config: ServerConfig) -> Arc<Self> {
Arc::new(Self {
db: utils::database::Database::new(&config).unwrap(),
plugins: Mutex::new(Vec::new()),
root: root.to_path_buf(),
config,
clients: Mutex::new(HashSet::new()),
@@ -72,9 +70,6 @@ impl Server {
)?;
// Initialize plugins
for plugin in self.plugins.lock().unwrap().iter_mut() {
plugin.init(self);
}
// Start server
let listener = TcpListener::bind(format!("0.0.0.0:{}", self.config.port))?;
@@ -167,11 +162,11 @@ impl Server {
'outer: loop {
let req = client.read()?;
if let Some(r) = &req {
for p in self.plugins.lock().unwrap().iter_mut() {
if p.on_request(r, client, self) {
continue 'outer;
}
}
// for p in self.plugins.lock().unwrap().iter_mut() {
// if p.on_request(r, client, self) {
// continue 'outer;
// }
// }
self.wrap_err(&client, self.call_request(r, &client))?;
}
-1
View File
@@ -3,5 +3,4 @@ pub mod database;
#[cfg(feature = "loader")]
pub mod loader;
pub mod logger;
pub mod plugin;
pub mod vfs;
-22
View File
@@ -1,22 +0,0 @@
use std::sync::Arc;
use crate::{
server::Server,
types::message::{ClientMessage, WsMessage},
utils::client::Client,
};
pub type DynPlugin = Box<dyn Plugin + Send + Sync>;
pub trait Plugin {
fn init(&mut self, server: &Arc<Server>);
#[allow(unused_variables)]
fn on_request(
&mut self,
req: &WsMessage<ClientMessage>,
client: &Client,
server: &Arc<Server>,
) -> bool {
false
}
}