Fixed rust, named the libraries sdk's, better examples

This commit is contained in:
2024-06-16 00:59:04 +03:00
parent 407faab33a
commit f55279b7ef
20 changed files with 229 additions and 226 deletions

View File

@@ -37,6 +37,8 @@ impl PlugMan {
self.load(entry.path().to_path_buf())?;
}
}
println!("INFO: Loaded {} plugins", self.plugins.len());
Ok(())
}
@@ -81,18 +83,18 @@ impl PlugMan {
#[derive(Debug)]
pub enum PluginError {
DlOpenError(dlopen::Error),
IoError(std::io::Error)
DlOpenError,
IoError
}
impl From<dlopen::Error> for PluginError {
fn from(value: dlopen::Error) -> Self {
Self::DlOpenError(value)
fn from(_: dlopen::Error) -> Self {
Self::DlOpenError
}
}
impl From<std::io::Error> for PluginError {
fn from(value: std::io::Error) -> Self {
Self::IoError(value)
fn from(_: std::io::Error) -> Self {
Self::IoError
}
}

View File

@@ -1,4 +1,4 @@
use std::{alloc::Layout, ffi::{c_char, CStr, CString}, path::PathBuf};
use std::{alloc::Layout, ffi::{c_char, c_uint, CStr, CString}, path::PathBuf};
use dlopen::raw::Library;
@@ -90,6 +90,10 @@ impl Plugin {
let s = unsafe {
(self.syms().poll)(buf as *mut i8, cap);
let len = libc::strlen(buf as *const i8);
if len > cap {
panic!("String len is bigger than allocatd");
}
String::from_raw_parts(buf, len, cap)
};