#libloading #dynamic #shared #loading #platform-independent #library

shared_lib

Wrapper around the libloading crate that aims to improve the system path and error handling

2 releases

0.1.1 Jun 15, 2024
0.1.0 Jun 14, 2024

#286 in Operating systems

39 downloads per month

MIT license

13KB
171 lines

shared_lib

Wrapper around libloading crate that is a binding around platform's dynamic library loading primitives with greatly improved memory safety. shared_lib aims to improve the system path handling by using a custom structure representing platform independent path. The library also returns custom enum variants to better distinguish different kinds of errors.

Instalation

cargo add shared_lib

or add shared_lib to your Cargo.toml file.

Usage

use shared_lib::*;
use std::path::PathBuf;

fn main() {
    let lib_path = LibPath::new(PathBuf::from("path/to/dir"), "library_name_no_ext".into());
    unsafe {
       let lib = SharedLib::new(lib_path).unwrap();
       let func = lib.get_fn::<fn(usize, usize) -> usize>("foo").unwrap();
       let result = func.run(1, 2);
       println!("Result = {}", result);
    }
}

Documentation

This library is available under the MIT License

Dependencies

~0.4–5MB
~18K SLoC