Struct snek::Snek
[−]
[src]
pub struct Snek { /* fields omitted */ }
This provides an interface for manually loading a dynamic library and
symbols from it. While this exists, it is more recommended to use the
snek!
macro to generate a wrapper for a library
automatically.
A Snek
instance contains nothing but a handle to the loaded library,
and provides a single method for loading symbols from the library. When
the instance is dropped, it unloads the library, so the lifetime of
any loaded symbols is tied to the lifetime of the Snek
instance.
For more information about using the loaded symbols see the
Symbol
documentation.
Example
match Snek::load("libexample.so") { Ok(snek) => match snek.symbol("add") { Ok(symbol) => println!("{}", unsafe { symbol.with( |add: extern fn(c_int, c_int) -> c_int| add(3, 7) ) }), _ => () }, _ => () }
Methods
impl Snek
[src]
fn load<P>(path: P) -> Result<Snek, Error> where
P: AsRef<Path>,
P: AsRef<Path>,
Attempt to load a dynamic library from the given path, returning a Snek
instance wrapping the handle.
If the load fails, this will return Error::LibraryLoadError
fn symbol<'a>(&'a self, symbol: &str) -> Result<Symbol<'a>, Error>
Attempt to load a symbol from the dynamic library, returning a
Symbol
instance wrapping it.
If the load fails, this will return Error::SymbolLoadError