[][src]Crate halt

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

Examples

Add this to Cargo.toml:

[dependencies]
halt = "0.3"

And this to main.rs:

use halt::Halt;
use std::{io, 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().unwrap();
    remote.resume().unwrap();
}

Structs

Halt

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

Invalid

The error type used in halt.

Remote

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

Type Definitions

Result

A specialized result type used in halt.