docs.rs failed to build hotswap-0.1.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build:
hotswap-0.6.0
rust-hotswap
A library for hotswapping running code with minimal effort.
Beware that the library is a completely unsafe prototype for now, and it will probably crash a lot.
Usage
- Using a nightly rust, import the plugin
hotswap
. - Annotate the functions you want to hotswap with the
#[hotswap]
modifier. - Add the
#![hotswap_header]
to the top of your program. - Add the
hotswap_start!()
macro to the entry point of your program, before you call any hotswapped functions.
Current Limitations
- Changing hotswapped function signatures WILL result in a segfault.
- Requires extra dependencies in the user application.
- Leaks a dynamic library on each swap.
Example
# Cargo.toml
[]
= "hotswapdemo"
= "0.1.0"
[]
= "hotswapdemo"
= ["dylib"]
= "src/main.rs"
[]
= "*"
= "*" # glob and libreloading are
= "*" # required dependencies for now.
// main.rs
use sleep;
use Duration;
And that is it! From there you can
> cargo run
Running `target\debug\hotswaptest.exe`
Foo: 123
Foo: 123
Foo: 123
and if you edit the printing code, changing it to
println!;
and recompiling the code on another terminal (or putting the running task in the background)
> cargo build --lib
Compiling hotswapdemo v0.1.0[...]
> fg
Foo: 123
Foo: 123
Bar: 123
Bar: 123
the running function will update automatically to the latest version without restarting the executable!