pub fn mediate<S: Into<Signal>>(signal: S) -> SignalHandleExpand description
Use this to get a SignalHandle representing a interrupt specified by Signal.
ยงExample
use addy::SIGWINCH;
use std::io::{Read, stdin};
fn main() -> Result<(), addy::Error> {
/* SIGWINCH is a POSIX interrupt signal */
addy::mediate(SIGWINCH)
.register("resized", |_signal| { println!("Screen Resized!"); })?
.enable()?;
/* Block so the program doesn't exit immediately
* Try resizing your terminal window :)
*/
let mut buffer = [0; 1];
loop {
stdin().read(&mut buffer);
}
Ok(())
}