interrupt-read 0.2.0

An simple implementation of an interruptable reader.
Documentation

interrupt-read License interrupt-read on crates.io interrupt-read on docs.rs

An interruptable Reader

This crate provides the InterruptReader, which can have its read operations interrupted by an Interruptor. They are acquired from the interrupt_reader::pair function, which returns an mpsc channel backed pair.

When Interruptor::interrupt is called, the InterruptReader will return an erro of kind ErrorKind::Interrupted. Otherwise, it will act like any normal Read struct.

Some things to note about this crate:

  • It functions by spawning a separate thread, which will actually read from the original Reader, so keep that in mind.
  • There is some (light) overhead over the read operations.
  • You should not wrap this struct in a BufReader since the struct already has its own internal buffer.
  • This reader doesn’t assume that Ok(0) is the end of input, and the spawned thread will only terminate if the InterruptReader is dropped.