[−][src]Crate wintrap
The wintrap
crate allows a Windows process to trap one or more abstracted
"signals", running a callback function in a dedicated thread whenever they
are caught while active.
Examples
wintrap::trap(&[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.
Structs
SignalStream | An asynchronous stream of Signals generated by trap_stream. |
Enums
Error | An error that may potentially be generated by trap. These errors will
rarely ever be produced, and you can unwrap |
Signal | Represents one of several abstracted "signals" available to Windows processes. A number of these signals may be associated with a single trap call. |
Functions
trap | Associates one or more Signals to an callback function to be executed in
a dedicated thread while |
trap_stream | Traps one or more Signals into a SignalStream. During the execution of the body function, all signals specified will be yielded as items in the stream. |