pub struct Dylib<'scope> { /* private fields */ }Expand description
An relocated dynamic library
Implementations§
Source§impl<'scope> Dylib<'scope>
impl<'scope> Dylib<'scope>
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<'scope> Freeze for Dylib<'scope>
impl<'scope> !RefUnwindSafe for Dylib<'scope>
impl<'scope> Send for Dylib<'scope>
impl<'scope> Sync for Dylib<'scope>
impl<'scope> Unpin for Dylib<'scope>
impl<'scope> !UnwindSafe for Dylib<'scope>
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