Module emf_core_base_rs::global::library[][src]

Global library api.

Example

use emf_core_base_rs::global::{LockToken, Unlock, library};
use emf_core_base_rs::library::{DEFAULT_HANDLE, Symbol};
use std::path::Path;
use std::ffi::CString;

let mut lock = LockToken::<Unlock>::lock();

let library_path = Path::new("path to my library");
let symbol_name = CString::new("add_function").unwrap();

let mut  library = library::load(&mut lock, &DEFAULT_HANDLE, &library_path)?;
let symbol: Symbol<extern "C" fn(i32, i32) -> i32> =
    library::get_function_symbol(
        &lock,
        &library,
        &symbol_name,
        |f| unsafe { std::mem::transmute(f) }
    )?;

assert_eq!(symbol.as_ref()(5, 8), 13);

Functions

create_library_handle

Creates a new unlinked library handle.

get_data_symbol

Fetches a data symbol from a library.

get_function_symbol

Fetches a function symbol from a library.

get_internal_library_handle

Fetches the internal handle linked with the library handle.

get_library_types

Copies the strings of the registered library types into a buffer.

get_loader_handle_from_library

Fetches the loader handle linked with the library handle.

get_loader_handle_from_type

Fetches the loader handle associated with the library type.

get_loader_interface

Fetches the interface of a library loader.

get_num_loaders

Fetches the number of registered loaders.

library_exists

Checks if a the library handle is valid.

link_library

Links a library handle to an internal library handle.

load

Loads a library. The resulting handle is unique.

register_loader

Registers a new loader.

remove_library_handle

Removes an existing library handle.

type_exists

Checks if a library type exists.

unload

Unloads a library.

unregister_loader

Unregisters an existing loader.