/live-reloading-rs

Live reloading for Rust programming

Primary LanguageRust

Live Reload

License Version number Documentation Travis CI

This is inspired by the article "Interactive Programming in C" by Chris Wellons, and the video "Loading Game Code Dynamically" from Handmade Hero by Casey Muratori.

The general idea is that your main host program is a wrapper around a dynamic library that does all the interesting work of your game. This means that you can simply reload the library while the game is still running, and have your game update live. As a consequence however, you can't have any global state in your library, everything must be owned by the host in order to avoid getting unloaded with the library.

Getting Started

Add this to your Cargo.toml:

[lib]
name = "<your library name>"
crate-type = ["cdylib"]

[dependencies]
live-reload = "0.2"

To do live reloading, you'll need to build both a library and a binary. Inside the host binary, you'll want to use live-reload with:

extern crate live_reload;

In the library, you need to use a macro to declare the live-reloading API, so you need:

#[macro_use] extern crate live_reload;

See the Documentation for instructions on how to use the library to create the library and host program.