Crates.io | hotload |
lib.rs | hotload |
version | 0.15.1 |
source | src |
created_at | 2024-08-31 13:02:34.369522 |
updated_at | 2024-10-11 14:16:21.288369 |
description | Zero cost hot update dynamic library; supporting DLL, SO |
homepage | |
repository | |
max_upload_size | |
id | 1358815 |
size | 24,131 |
[
use dlopen2::wrapper::{Container, WrapperApi};
use hotload::types::Hotload;
// Generate the following rust calling methods
hotload::gen_rust_no_mangle!((MyApi, "../call_lib/src/lib.rs"));
// #[derive(WrapperApi)]
// struct MyApi {
// test_print: fn(msg: String),
// init_data: fn(msg: String),
// stop_runtime: fn(),
// }
fn main(){
let dll: Hotload<MyApi> = Hotload::new("../call_lib/target/release/call_lib.dll");
// "dll created" or "file rename to" is actively loaded
dll.init_load(|_, _| {}).unwrap();
let mut count = 0;
loop {
count += 1;
dll.test_print(format!("msg{count}"));
}
}
Zero cost hot update dynamic library; supporting DLL, SO
Feature | dlopen2 | hotload | hot-lib-reloader |
---|---|---|---|
Basic functionality | Yes | Yes | Yes |
Multiplatform | Yes | Yes | Yes |
Dangling symbol prevention | Yes | Yes | Yes |
Thread safety | Yes | Yes | Yes |
Loading of symbols into structures | Yes | Yes | Yes |
Overhead | Minimal | Minimal | Minimal |
Low-level, unsafe API | Yes | Yes | Yes |
Object-oriented friendly | Yes | Yes | Yes |
Load from the program itself | Yes | Yes | Yes |
Obtaining address information (dladdr) | Yes | Yes | Yes |
Auto reload | No | Yes | Yes |
Is haved load new dll event | No | Yes | No |
Zero cost, Is not lock | No | Yes | No |
Generate rust call method | No | Yes | Yes |
Cargo.toml:
[dependencies]
dlopen2 = "0.6"
hotload = "0.9"
This code is licensed under the MIT license.
Special thanks to dlopen2 and hot-lib-reloader