Read to Timeout

An extension trait for trait std::io::Read

The std::io::Read trait implements many read operations, but is doesn't contain a simple read method where timeout is an expected behaviour

This trait provides readtotimeout and readtopatternortimeout that are implemented for all types that implements std::io::Read

Usage

ReadToTimeout::readtotimeout

readtotimeout behaves just like readtoend, except on timeout, this method returns Ok(bytes_read) instead of Err(..)

ReadToTimeout::readtopatternortimeout

readtopatternortimeout is similar to read_to_timeout

But when a specified pattern is reached, return Ok(bytes_read) immediately

Note

If the provided buffer is non-empty, while at least one byte must be read before any pattern match, it is possible for pattern to match on old bytes.