Crates.io | wintrap |
lib.rs | wintrap |
version | 0.3.1 |
source | src |
created_at | 2019-01-18 05:02:33.224826 |
updated_at | 2021-05-26 01:32:13.407662 |
description | A Windows signal-trapping library |
homepage | |
repository | https://github.com/elizagamedev/wintrap-rs |
max_upload_size | |
id | 109271 |
size | 43,316 |
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.
wintrap::trap(vec![wintrap::Signal::CtrlC, wintrap::Signal::CloseWindow], |signal| {
// handle signal here
println!("Caught a signal: {:?}", signal);
}, || {
// do work
println!("Doing work");
}).unwrap();
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.