Binary

interface Binary

Binary represents a fixed-size multi-read byte block, which is not attached to the Input which was used to create it. The binary could be associated with a resource, but it should guarantee that when someone is trying to read the binary, this resource is re-acquired.

Types

Companion
Link copied to clipboard
common
object Companion

Functions

read
Link copied to clipboard
common
abstract fun <R> read(offset: Int = 0, atMost: Int = size - offset, block: Input.() -> R): R

Read maximum of atMost bytes as input from the binary, starting at offset. The generated input is always closed when leaving scope, so it could not be leaked outside of scope of block.

Properties

size
Link copied to clipboard
common
abstract val size: Int

Inheritors

BinaryView
Link copied to clipboard

Extensions

get
Link copied to clipboard
common
operator fun Binary.get(range: IntRange): BinaryView
readWith
Link copied to clipboard
common
fun <T : Any> Binary.readWith(format: IOFormat<T>): T

Read given binary as object using given format

toByteArray
Link copied to clipboard
common
fun Binary.toByteArray(): ByteArray

Produce a buildByteArray representing an exact copy of this Binary

view
Link copied to clipboard
common
fun Binary.view(start: Int, size: Int): BinaryView