#dll #file-format #dylib #dlopen #so #hotupdate

hotload

Zero cost hot update dynamic library; supporting DLL, SO

14 releases (5 breaking)

0.15.2 Nov 17, 2024
0.15.1 Oct 11, 2024
0.14.2 Sep 12, 2024
0.12.4 Sep 10, 2024
0.9.1 Aug 31, 2024

#669 in Parser implementations

Download history 147/week @ 2024-08-25 455/week @ 2024-09-01 568/week @ 2024-09-08 98/week @ 2024-09-15 18/week @ 2024-09-22 13/week @ 2024-09-29 216/week @ 2024-10-06 66/week @ 2024-10-13 3/week @ 2024-10-20 10/week @ 2024-11-03 114/week @ 2024-11-17

124 downloads per month

MIT license

25KB
529 lines

hotload

[crates.io

Quick example

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}"));
    }
}

Features

Main features

  • Zero cost hot update dynamic library; supporting DLL, SO

Comparison with other libraries

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

Usage

Cargo.toml:

[dependencies]
dlopen2 = "0.6"
hotload = "0.9"

Documentation

Cargo documentation

License

This code is licensed under the MIT license.

Changelog

GitHub

Acknowledgement

Special thanks to dlopen2 and hot-lib-reloader

Dependencies

~3–11MB
~114K SLoC