Hello,
I am using libloading
and a dylib
library. Inside my main.rs
I am attempting to load the function Symbol for a function that passes a pointer to a specs::DispatcherBuilder
The function inside by dylib is declared as:
#[no_mangle]
pub fn register_plugin<'a, 'b>(
dispatcherBuilder: *mut DispatcherBuilder<'a, 'b>,
) -> *mut DispatcherBuilder<'a, 'b> {
let func: Symbol<fn(*mut DispatcherBuilder) -> *mut DispatcherBuilder> =
unsafe { plugs.plugins[0].lib.get(b"register_plugin").unwrap() };
However, rustc
is complaining about missing lifetimes:
error[E0106]: missing lifetime specifiers
--> src/main.rs:105:57
|
105 | let func: Symbol<fn(*mut DispatcherBuilder) -> *mut DispatcherBuilder> =
| ^^^^^^^^^^^^^^^^^ expected 2 lifetime parameters
If I try and add lifetime parameters inside the Symbol like I did in the dylib, I am told that I am using an unspecified lifetime:
error[E0261]: use of undeclared lifetime name `'a`
--> src/main.rs:105:75
|
105 | let func: Symbol<fn(*mut DispatcherBuilder) -> *mut DispatcherBuilder<'a, 'b>> =
| ^^ undeclared lifetime
I am a total beginner and I clearly feel way in over my head. If there is a simpler solution to what I am trying to accomplish, I would appreciate any suggestions.
Thanks!