scanner: make plugin interface ffi-safe with handle-based registry

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I8e4790db3cc29f84f4e0d7d8eff36c2c6a6a6964
This commit is contained in:
raf 2026-02-18 22:49:12 +03:00
commit f4961c7f95
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
9 changed files with 93 additions and 44 deletions

View file

@ -1,23 +1,17 @@
#![allow(improper_ctypes)]
use pscand_core::helpers::{ResourceHelper, SystemHelper};
use pscand_core::scanner::{MetricValue, Scanner};
use pscand_core::Result;
use std::collections::HashMap;
use std::time::Duration;
#[derive(Default)]
struct SystemScanner {
_prev_cpu: Option<HashMap<String, f64>>,
}
impl Default for SystemScanner {
fn default() -> Self {
Self { _prev_cpu: None }
}
}
#[unsafe(no_mangle)]
pub extern "C" fn pscand_scanner() -> Box<dyn Scanner> {
Box::new(SystemScanner::default())
#[no_mangle]
pub extern "C" fn pscand_scanner() -> *mut std::os::raw::c_void {
Box::into_raw(Box::new(SystemScanner::default())) as *mut std::os::raw::c_void
}
impl Scanner for SystemScanner {