Initial commit
This commit is contained in:
9
main/Cargo.toml
Normal file
9
main/Cargo.toml
Normal file
@@ -0,0 +1,9 @@
|
||||
[package]
|
||||
name = "main"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
libloading = "0.8"
|
||||
shared = { path = "../shared" }
|
||||
stabby = { workspace = true }
|
||||
19
main/src/main.rs
Normal file
19
main/src/main.rs
Normal file
@@ -0,0 +1,19 @@
|
||||
use libloading::{Library, Symbol};
|
||||
use shared::{Input, Output};
|
||||
|
||||
type ProcessFn = unsafe extern "C" fn(input: Input) -> Output;
|
||||
|
||||
fn main() {
|
||||
unsafe {
|
||||
let lib = Library::new("target/debug/libplugin.so").expect("Failed to load plugin");
|
||||
|
||||
let process: Symbol<ProcessFn> = lib.get(b"process").expect("Failed to load symbol");
|
||||
|
||||
let input = Input { a: 3, b: 4 };
|
||||
|
||||
let output: Output = process(input);
|
||||
|
||||
println!("Sum: {}", output.sum);
|
||||
println!("Product: {}", output.product);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user