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.


match Snek::load("") {
    Ok(snek) => match snek.symbol("add") {
        Ok(symbol) => println!("{}", unsafe { symbol.with(
            |add: extern fn(c_int, c_int) -> c_int| add(3, 7)
        ) }),

        _ => ()

    _ => ()


impl Snek

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

Attempt to load a symbol from the dynamic library, returning a Symbol instance wrapping it.

If the load fails, this will return Error::SymbolLoadError

Trait Implementations

impl Debug for Snek

Formats the value using the given formatter.

impl Drop for Snek

A method called when the value goes out of scope. Read more