| Crates.io | shared_lib |
| lib.rs | shared_lib |
| version | 0.1.1 |
| created_at | 2024-06-14 10:59:54.725858+00 |
| updated_at | 2024-06-15 10:50:55.660498+00 |
| description | Wrapper around the libloading crate that aims to improve the system path and error handling. |
| homepage | |
| repository | https://github.com/tomtar00/shared_lib |
| max_upload_size | |
| id | 1271850 |
| size | 13,293 |
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.
cargo add shared_lib
or add shared_lib to your Cargo.toml file.
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);
}
}
This library is available under the MIT License