Struct ctrlc::CtrlC

source · []
pub struct CtrlC;

Implementations

Sets up the signal handler for Ctrl-C using default polling rate of 100ms.

Example
CtrlC::set_handler(|| println!("Hello world!"));

Sets up the signal handler for Ctrl-C using a custom polling rate. The polling rate is the amount of time the internal spinloop of CtrlC sleeps between iterations. Because condition variables are not safe to use inside a signal handler, CtrlC (from version 1.1.0) uses a spinloop and an atomic boolean instead.

Normally you should use set_handler instead, but if the default rate of 100 milliseconds is too fast or too slow for you, you can use this routine instead to set your own.

Example
CtrlC::set_handler_with_polling_rate(
    || println!("Hello world!"),
    Duration::from_millis(10)
);

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.