wintrap

Crates.iowintrap
lib.rswintrap
version0.3.1
sourcesrc
created_at2019-01-18 05:02:33.224826
updated_at2021-05-26 01:32:13.407662
descriptionA Windows signal-trapping library
homepage
repositoryhttps://github.com/elizagamedev/wintrap-rs
max_upload_size
id109271
size43,316
Eliza (elizagamedev)

documentation

https://docs.rs/wintrap/0.3.1/

README

wintrap-rs

The wintrap crate allows a Windows process to trap one or more abstracted "signals", running an asynchronous callback function whenever they are caught while active.

Examples

wintrap::trap(vec![wintrap::Signal::CtrlC, wintrap::Signal::CloseWindow], |signal| {
    // handle signal here
    println!("Caught a signal: {:?}", signal);
}, || {
    // do work
    println!("Doing work");
}).unwrap();

Caveats

Please note that it is not possible to correctly trap Ctrl-C signals when running programs via cargo run. You will have to run them directly via the target directory after building.

Commit count: 10

cargo fmt