Struct dynlib::DynLibWin
[−]
[src]
pub struct DynLibWin { /* fields omitted */ }
DynLib
The object that represents a dynamic library loaded into memory. This object is special to Microsoft Windows. You'll want to compile this program with the msvc tool chain. And when deploying ensure the Visual C++ runtime is deployed to the target machine.
DynLib does not implement drop. So it will not be de-allocated. You must manually drop dynamic links.
Methods
impl DynLibWin
[src]
fn load_function(&self, symbol: &str) -> Result<VoidPtr, Error>
Load a function
Ensure the names are mangled correctly. The null terminator will be appened in this function. The symbol you pass will be re-allocated within this function.
One needs to cast the VoidPtr
type to a a function. This is
accomplished via the:
let func: extern "Rust" fn([YOUR ARGS] -> [YOUR RESULT] = unsafe{ mem::transmute([VOIDPTR]);
One should not the ABI is not burned in stone. You will have to change the value based on what you are loading. The values supported by Rust are:
cdecl
, stdcall
, fastcall
, vectorcall
, aapcs
, `win64
,
sysv64
, Rust
, C
, system
, rust-intrinsic
, rust-all
,
and platform-intrinsic
. Ensure your caps are correct.
fn free(self) -> Result<(), Error>
Free the Library
This will unload the DLL and invalidate all loaded functions. Use with care.