4.46. kink/io/BIN_INPUT

BIN_INPUT mod provides input implementation which extracts bytes from bin vals.

4.46.1. BIN_INPUT.new(Bin)

BIN_INPUT.new makes an input which extracts bytes from Bin.

Bin must be a bin.



:In <- BIN_INPUT.new(BIN.of(1 2 3 4 5 6))
stdout.print_line(In.read_byte.repr)    # => [1]
stdout.print_line(In.read_bin(2).repr)  # => [BIN.of(0x02 0x03)]
stdout.print_line(In.read_all.repr)     # => BIN.of(0x04 0x05 0x06)

The result input does not cause IO errors.

.close method of the result input does nothing, thus you don't have to call .close for the input.