[][src]Function addy::mediate

pub fn mediate<S: Into<Signal>>(signal: S) -> SignalHandle

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(())
}