Class: BlockStream

The io:BlockStream is used to initialize a stream of type io:Block. This io:BlockStream refers to the stream that is embedded to the I/O byte channels.

Constructor

Initialize a BlockStream using an io:ReadableByteChannel.

init (ReadableByteChannel readableByteChannel, int blockSize)
  • readableByteChannel ReadableByteChannel
  • The io:ReadableByteChannel that this block stream is referred to

  • blockSize int
  • The size of a block as an integer

Methods

next

The next function reads and returns the next block of the related stream.

close

Closes the stream.

function next() returns record {| value Block |} | Error?
Isolated Function

The next function reads and returns the next block of the related stream.

Return Type

(record {| value Block |} | Error?)

An io:Block when a block is avaliable in the stream or returns () when the stream reaches the end

close

function close() returns Error?
Isolated Function

Closes the stream. The primary usage of this function is to close the stream without reaching the end If the stream reaches the end, the blockStream.next() will automatically close the stream.

Return Type

(Error?)

() when the closing was successful or an io:Error