Skip to main content

Crate interrupt_read

Crate interrupt_read 

Source
Expand description

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.

Structs§

InterruptError
An error ocurred while calling Interruptor::interrupt.
InterruptReader
Interruptor
An interruptor for an InterruptReader.

Functions§

pair
Returns a pair of an InterruptReader and an Interruptor.