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:
parent
4f9c7057ff
commit
f4961c7f95
9 changed files with 93 additions and 44 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue