pub struct Dylib { /* private fields */ }
Expand description
An relocated dynamic library
Implementations§
Source§impl Dylib
impl Dylib
Sourcepub fn needed_libs(&self) -> &[&str]
pub fn needed_libs(&self) -> &[&str]
Get the needed libs’ name of the elf object.
Sourcepub unsafe fn get<'lib, T>(&'lib self, name: &str) -> Result<Symbol<'lib, T>>
pub unsafe fn get<'lib, T>(&'lib self, name: &str) -> Result<Symbol<'lib, T>>
Get a pointer to a function or static variable by symbol name.
The symbol is interpreted as-is; no mangling is done. This means that symbols like x::y
are
most likely invalid.
§Safety
Users of this API must specify the correct type of the function or variable loaded.
§Examples
unsafe {
let awesome_function: Symbol<unsafe extern fn(f64) -> f64> =
lib.get("awesome_function").unwrap();
awesome_function(0.42);
}
A static variable may also be loaded and inspected:
unsafe {
let awesome_variable: Symbol<*mut f64> = lib.get("awesome_variable").unwrap();
**awesome_variable = 42.0;
};
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Dylib
impl !RefUnwindSafe for Dylib
impl Send for Dylib
impl Sync for Dylib
impl Unpin for Dylib
impl !UnwindSafe for Dylib
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more