stream.read_at_least

Synopsis

local stream = require "stream"
stream.read_at_least(io_object, buffer: byte_span, minimum: integer) -> integer

Description

Read data until a minimum number of bytes has been transferred and blocks current fiber until it completes or errs.

Returns the number of bytes read.

This operation is implemented in terms of zero or more calls to the stream’s async_read_some function, and is known as a composed operation. The program must ensure that the stream performs no other read operations (such as async_read, the stream’s async_read_some function, or any other composed operations that perform reads) until this operation completes.