Class: BlockStream

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

Constructor

Initialize a BlockStream using a 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 return the next block of the related stream.

close

Close the stream.

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

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

Return Type

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

Returns a io:Block when a block is avaliable in the stream or return null when the stream reaches the end

close

function close() returns Error?
Isolated Function

Close 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?)

Returns null when the closing was successful or an io:Error