getByteString

fun ByteArray.getByteString(offset: Int, numBytes: Int): ByteString

Extracts a ByteString from a portion of the byte array.

This function creates a ByteString from a specified range of bytes within the ByteArray. It allows you to extract a subset of bytes starting at a given offset and continuing for numBytes in length.

Return

A ByteString containing the extracted bytes. If numBytes is 0, an empty ByteString is returned.

Parameters

offset

The starting index in the ByteArray from which to begin the extraction. Must be a non-negative integer.

numBytes

The number of bytes to extract, starting from the offset. Must be a non-negative integer.

Throws

If the offset or numBytes is negative, or if the requested range (offset + numBytes) extends beyond the bounds of the ByteArray.