pub trait ExternLibrary {
// Required method
fn get_sym(&self, name: &str) -> Option<*const ()>;
}Required Methods§
sourcefn get_sym(&self, name: &str) -> Option<*const ()>
fn get_sym(&self, name: &str) -> Option<*const ()>
Get the symbol of the dynamic library, and the return value is the address of the symbol
§Examples
#[derive(Debug, Clone)]
struct MyLib(Arc<Library>);
impl ExternLibrary for MyLib {
fn get_sym(&self, name: &str) -> Option<*const ()> {
let sym: Option<*const ()> = unsafe {
self.0.get::<*const usize>(name.as_bytes())
.map_or(None, |sym| Some(sym.into_raw().into_raw() as _))
};
sym
}
}