[][src]Macro dl_api::link

macro_rules! link {
    ($sname: ident, $l: expr, { $(fn $fname: ident($($sarg: ident: $farg: ty),* $(,)?) -> $fret:ty);* $(;)? }) => { ... };
}

Macro to generate the API struct.

// Shared object: either "libmylibrary.so.1", "mylibrary-1.dll" or "libMyLibrary.dylib"
dl_api::link!(MyApi, "libmylibrary.so.1", {
    fn cFunction(param_name: *mut u32) -> u32;
});

fn main() {
    let api = MyApi::new().unwrap(); // unwrap the `Result`.

    let rtn: u32 = unsafe {
        (api.cFunction)(std::ptr::null_mut())
    };
}