read-to-timeout

Crates.ioread-to-timeout
lib.rsread-to-timeout
version0.1.4
sourcesrc
created_at2022-09-15 15:42:54.826572
updated_at2022-10-11 03:03:26.698614
descriptionExtension on std::io::Read trait where timeout is the expected behaviour
homepage
repositoryhttps://gitlab.com/ythan-zhang/read-to-timeout
max_upload_size
id666760
size5,832
YthanZhang (YthanZhang)

documentation

README

Read to Timeout

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

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

This trait provides read_to_timeout and read_to_pattern_or_timeout that are implemented for all types that implements std::io::Read

Usage

ReadToTimeout::read_to_timeout

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

ReadToTimeout::read_to_pattern_or_timeout

read_to_pattern_or_timeout 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.

Commit count: 8

cargo fmt