[][src]Crate halt

Provides functionality for pausing, stopping, and resuming iterators, readers, and writers.

Examples

Add this to Cargo.toml:

[dependencies]
halt = "0.2"

And this to main.rs:

use halt::Halt;
use std::io;
use std::thread;

fn main() {
    // Wrap a reader in the halt structure.
    let mut halt = Halt::new(io::repeat(0));
    // Get a remote to the reader.
    let remote = halt.remote();
    // Copy forever into a sink, in a separate thread.
    thread::spawn(move || io::copy(&mut halt, &mut io::sink()).unwrap());
    // The remote can now be used to either pause, stop, or resume the reader from the main thread.
    remote.pause();
    remote.resume();
}

Structs

Halt

A wrapper that makes it possible to pause, stop, and resume iterators, readers, and writers.

Remote

A remote that allows for pausing, stopping, and resuming the Halt wrapper.

Enums

Error

The error type used in halt.

Type Definitions

Result

A specialized result type for halt.