Module emf_core_base_rs::library[][src]

Library api

Example

use emf_core_base_rs::CBaseAPI;
use emf_core_base_rs::library::{LibraryAPI, DEFAULT_HANDLE, Symbol, Error};
use std::path::Path;
use std::ffi::CString;

let result = CBaseAccess::lock(base_interface, |interface| -> Result<i32, Error> {
    let library_path = Path::new("path to my library");
    let symbol_name = CString::new("add_function").unwrap();

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

    let result = symbol.as_ref()(5, 8);
    LibraryAPI::unload(interface, library)?;
    Ok(result)
});

assert_eq!(result.is_ok(), true);
assert_eq!(result.unwrap(), 13);

Modules

library_loader

API of a library loader.

Structs

InternalLibrary

A loader handle.

Library

A library handle.

Loader

A loader handle.

Symbol

A library symbol.

Enums

Error

Errors of the library api.

Constants

DEFAULT_HANDLE

Handle of the default loader.

LOADER_TYPE_MAX_LENGTH

Max length of a library type.

NATIVE_LIBRARY_TYPE_NAME

Name of the native library type.

Traits

LibraryAPI

Idiomatic library api.

Type Definitions

LibraryType

Library type.