| Crates.io | read-to-timeout |
| lib.rs | read-to-timeout |
| version | 0.3.1 |
| created_at | 2022-09-15 15:42:54.826572+00 |
| updated_at | 2025-01-16 13:53:23.808889+00 |
| description | Extension on std::io::Read trait where timeout is the expected behaviour |
| homepage | |
| repository | https://gitlab.com/ythan-zhang/read-to-timeout |
| max_upload_size | |
| id | 666760 |
| size | 8,687 |
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_timeout_or_pattern that are implemented for all types that implements std::io::Read
read_to_timeout behaves just
like read_to_end, except on timeout, this method
returns Ok(bytes_read) instead of Err(..)
read_to_timeout_or_bytes is similar
to read_to_timeout
But when read byte count reaches given max_byte, this function returns
Ok(bytes_read) immediately
read_to_timeout_or_pattern is
similar to read_to_timeout
But when a specified pattern is reached, return Ok(bytes_read) immediately
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.