shared_lib

Crates.ioshared_lib
lib.rsshared_lib
version0.1.1
sourcesrc
created_at2024-06-14 10:59:54.725858
updated_at2024-06-15 10:50:55.660498
descriptionWrapper around the libloading crate that aims to improve the system path and error handling.
homepage
repositoryhttps://github.com/tomtar00/shared_lib
max_upload_size
id1271850
size13,293
Tomasz Tarnowski (tomtar00)

documentation

https://docs.rs/shared_lib

README

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

Commit count: 5

cargo fmt