Skip to main content

Module bounded_read

Module bounded_read 

Source
Expand description

Size-capped reads of streams whose length the caller does not control.

Each reader takes at most max + 1 bytes from the stream: one byte past the cap is enough to tell a stream of exactly max bytes from a longer one. None means more than max bytes were available. How that is reported is left to the caller, so each call site keeps its own error.

Functionsยง

read_to_end_bounded
Read reader to its end. Some holds every byte when the stream has at most max bytes, None means it had more, and a read error is returned unchanged.
read_to_end_bounded_async
Async counterpart of read_to_end_bounded over a tokio reader.