| Crates.io | hotpatch_macros |
| lib.rs | hotpatch_macros |
| version | 0.3.0 |
| created_at | 2020-12-18 23:29:07.656074+00 |
| updated_at | 2021-02-09 03:23:09.382268+00 |
| description | Macros for hotpatch |
| homepage | |
| repository | https://github.com/Shizcow/hotpatch |
| max_upload_size | |
| id | 324469 |
| size | 21,326 |
This crate is primarily used to load new function definitions from shared object files in an exceedingly easy way.
Key features:
The following shows how dead-simple this crate is to use:
// main.rs
use hotpatch::*;
#[patchable]
fn foo() { }
fn main() -> Result<(), Box<dyn std::error::Error>> {
foo(); // does nothing
foo.hotpatch_lib("libsomething.so")?;
foo(); // does something totally different!
foo.hotpatch_fn(|| println!("Dyamic!"))?;
foo(); // even more modification!
Ok(())
}
Don't hotpatch the function you're currently in, or any of its parents.
Because hotpatch doesn't allow multiple function definitions to be in
affect at the same time, this will cause a deadlock.
It is possible to do this with the force functions, however they are
unsafe, as in a multithreaded enironment this could cause multiple
function definitions to be in effect at once.
For more information, see the docs.
This crate is still has a long way to go before being "finished". Below are some items left to do. Submit an issue or PR to this section for feature requests!
no_std and use features to give the widest possible functionality
lazy_static#[patchable] ||() to generate from a closure (is this even possible?)