Object - io : ReadableDataChannel

Represents a data channel for reading data.

Constructor

__init

(ReadableByteChannel byteChannel, ByteOrder bOrder)

  • byteChannel ReadableByteChannel
  • The channel, which would represent the source to read/write data

  • bOrder ByteOrder <BE|LE> BE
  • network byte order

Methods

Reads a 16 bit integer.
Reads a 32 bit integer.
Reads a 64 bit integer.
Reads a 32 bit float.
Reads a 64 bit float.
Reads a byte and convert its value to boolean.
Reads the string value represented through the provided number of bytes.
Reads a variable length integer.
Closes the data channel.

readInt16

()

returns int | Error
Reads a 16 bit integer.
 int|io:Error result = dataChannel.readInt16();
  • Return Type

    (int | Error)
  • The value of the integer, which is read or else an io:Error if any error occurred

readInt32

()

returns int | Error
Reads a 32 bit integer.
 int|io:Error result = dataChannel.readInt32();
  • Return Type

    (int | Error)
  • The value of the integer, which is read or else an io:Error if any error occurred

readInt64

()

returns int | Error
Reads a 64 bit integer.
 int|io:Error result = dataChannel.readInt64();
  • Return Type

    (int | Error)
  • The value of the integer, which is read or else an io:Error if any error occurred

readFloat32

()

returns float | Error
Reads a 32 bit float.
 float|io:Error result = dataChannel.readFloat32();
  • Return Type

    (float | Error)
  • The value of the float which is read or else io:Error if any error occurred

readFloat64

()

returns float | Error
Reads a 64 bit float.
 float|io:Error result = dataChannel.readFloat64();
  • Return Type

    (float | Error)
  • The value of the float which is read or else io:Error if any error occurred

readBool

()

returns boolean | Error
Reads a byte and convert its value to boolean.
 boolean|io:Error result = dataChannel.readBool();
  • Return Type

    (boolean | Error)
  • boolean value which is read or else io:Error if any error occurred

readString

(int nBytes, string encoding)

returns string | Error
Reads the string value represented through the provided number of bytes.
 string|io:Error string = dataChannel.readString(10, "UTF-8");

Parameters

  • nBytes int
  • Specifies the number of bytes, which represents the string

  • encoding string
  • Specifies the char-set encoding of the string

  • Return Type

    (string | Error)
  • The value of the string or else io:Error if any error occurred

readVarInt

()

returns int | Error
Reads a variable length integer.
 int|io:Error result = dataChannel.readVarInt();
  • Return Type

    (int | Error)
  • The value of the integer which is read or else io:Error if any error occurred

close

()

returns Error?
Closes the data channel.
 io:Error? err = dataChannel.close();
  • Return Type

    (Error?)
  • () if the channel is closed successfully or else an io:Error if any error occurred