DataAccessor

Defines an interface for random-access data reading.

Implementations should support reading bytes from a random-access data source (e.g., memory, file, mapped region). The interface guarantees consistent behavior across different sources, including strict parameter validation.

Inheritors

Types

Link copied to clipboard
object Companion

Checks whether the arguments to a read operation are valid. This method is intended for internal use in implementing readAtMost or readFully.

Properties

Link copied to clipboard
abstract val size: Long

The total size (in bytes) of the data accessible through this accessor.

Functions

Link copied to clipboard
expect abstract fun close()
Link copied to clipboard
open fun readAtMost(pos: Long, buf: ByteArray): Int

Reads at most buf.size bytes from the data source starting at pos into the given buf.

abstract fun readAtMost(pos: Long, buf: ByteArray, off: Int, len: Int): Int

Reads at most len bytes from the data source starting at the given pos into the buf array, starting at offset off.

Link copied to clipboard

Reads at most buf.size bytes from the data source starting at the 32-bit pos into the given buf.

Reads at most buf.size bytes from the data source starting at the 64-bit pos into the given buf.

inline fun DataAccessor.readAtMost(pos: Address32, buf: ByteArray, off: Int, len: Int): Int
inline fun DataAccessor.readAtMost(pos: Address64, buf: ByteArray, off: Int, len: Int): Int

Reads at most len bytes from the data source starting at the given pos into the buf array, starting at offset off.

Link copied to clipboard
open fun readFully(pos: Long, buf: ByteArray)

Reads exactly buf.size bytes starting at pos into the buffer.

open fun readFully(pos: Long, buf: ByteArray, off: Int, len: Int)

Reads exactly len bytes starting at pos into buf, beginning at offset off.

Link copied to clipboard
inline fun DataAccessor.readFully(pos: Address32, buf: ByteArray)

Reads exactly buf.size bytes starting at the 32-bit pos into the buffer.

inline fun DataAccessor.readFully(pos: Address64, buf: ByteArray)

Reads exactly buf.size bytes starting at the 64-bit pos into the buffer.

inline fun DataAccessor.readFully(pos: Address32, buf: ByteArray, off: Int, len: Int)

Reads exactly len bytes starting at the 32-bit pos into buf, beginning at offset off.

inline fun DataAccessor.readFully(pos: Address64, buf: ByteArray, off: Int, len: Int)

Reads exactly len bytes starting at the 64-bit pos into buf, beginning at offset off.