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
BufReadersince 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 theInterruptReaderis dropped.
Structs§
- Interrupt
Error - An error ocurred while calling
Interruptor::interrupt. - Interrupt
Reader - Interruptor
- An interruptor for an
InterruptReader.
Functions§
- pair
- Returns a pair of an
InterruptReaderand anInterruptor.