Skip to content

Latest commit

 

History

History
29 lines (21 loc) · 688 Bytes

README.md

File metadata and controls

29 lines (21 loc) · 688 Bytes

Decan

[insert picture of half-open can]

A no-nonsense dynamic library loading crate.

Takes inspiration both from libloading and dlopen.

Example usage

use std::{path::{Path, PathBuf}, process::Command};

use decan::{can::Can, SymbolGroup};

#[derive(SymbolGroup)]
pub struct DecanTestlib {
    pub print_message: extern "C" fn(),
    pub square_int: Option<extern "C" fn(i32) -> i32>,
}

#[test]
fn main() {
    let can = unsafe { Can::<_, DecanTestlib>::load("libdecan_testlib.so").unwrap() };

    (can.print_message)();
    assert_eq!((can.square_int.unwrap())(2), 4);
}