Stream.readAllAsync() Overload 1

DESCRIPTION

Read exactly the specified amount of bytes asynchronously.

Closure is invoked with a success indication when all bytes are read. Or an error if all bytes could not be read (EOF or an error occurs or stream is stopped).

DECLARATION

    public func readAllAsync(length: Int, closure: @escaping AsyncDataReceiver) 

PARAMETERS

length:
The number of bytes to read
closure:
Invoked when the operation completes, see synchronous readAll() for possible errors.

Overload 2

DESCRIPTION

Read exactly the specified amount of bytes asynchronously.

If all bytes could not be read (EOF or an error occurs or stream is stopped), an error is thrown.

DECLARATION

    public func readAllAsync(length: Int) async throws -> Data 

PARAMETERS

length:
The number of bytes to read

THROWS ERRORS

EOF:
if end of file is reached
STOPPED:
if the stream is stopped
OPERATION_IN_PROGRESS:
if another read is in progress

RETURNS

the data read