class NativeByteBuffer
source · line 28public class NativeByteBuffer private constructor() : Closeable
- Supertype
Closeable - Inherited
fun dispose(): Unit· Closeable
Owned growable native byte storage with separate read and write positions. Outstanding native borrows restrict mutation and closure; explicitly close the buffer after use.
function compact
source · line 206public fun compact(): Unit
Moves unread bytes to offset zero and resets positions around that content.
function writeUInt64
source · line 495public fun writeUInt64(value: UInt64, order: ByteOrder): Unit
Appends 8 bytes representing UInt64 in the selected byte order and advances the write position.
parameter value
source · line 495value: UInt64
parameter order
source · line 495order: ByteOrder
function readInt8
source · line 406public fun readInt8(): Int8
Reads 1 bytes as Int8 and advances the read position.
property isClosed
source · line 80public val isClosed: Boolean
get: public read-only
Whether this owned resource has been closed.
getter get
source · line 80get(): Boolean
property readPosition
source · line 48public val readPosition: Long
get: public read-only
The absolute offset of the next readable byte.
getter get
source · line 48get(): Long
function readDouble
source · line 442public fun readDouble(order: ByteOrder): Double
Reads 8 bytes as Double in the selected byte order and advances the read position.
parameter order
source · line 442order: ByteOrder
property capacity
source · line 40public val capacity: Long
get: public read-only
The allocated byte capacity.
getter get
source · line 40get(): Long
function writeBytes
source · line 337public fun writeBytes(array: List<Byte>, offset: Long = 0L, count: Long = array.size - offset): Unit
Appends the selected array region and advances the write position.
parameter array
source · line 337array: List<Byte>
parameter count
source · line 337count: Long = array.size - offset
parameter offset
source · line 337offset: Long = 0L
function withReadableBytes
source · line 517@Unsafe
public fun <R> withReadableBytes(block: (Ptr<Byte>?, Long) -> R): R
Borrows the readable pointer and length only for the callback; the pointer must not escape. This operation does not consume bytes.
parameter block
source · line 518block: (Ptr<Byte>?, Long) -> R
type parameter R
source · line 518R
function readUInt8
source · line 410public fun readUInt8(): UInt8
Reads 1 bytes as UInt8 and advances the read position.
function readUInt64
source · line 434public fun readUInt64(order: ByteOrder): UInt64
Reads 8 bytes as UInt64 in the selected byte order and advances the read position.
parameter order
source · line 434order: ByteOrder
function readByte
source · line 279public fun readByte(): Byte
Reads one byte and advances the read position.
function writeFloat
source · line 502public fun writeFloat(value: Float, order: ByteOrder): Unit
Appends 4 bytes representing Float in the selected byte order and advances the write position.
parameter value
source · line 502value: Float
parameter order
source · line 502order: ByteOrder
function readUInt16
source · line 418public fun readUInt16(order: ByteOrder): UInt16
Reads 2 bytes as UInt16 in the selected byte order and advances the read position.
parameter order
source · line 418order: ByteOrder
function writeUInt8
source · line 453public fun writeUInt8(value: UInt8): Unit
Appends 1 bytes representing UInt8 and advances the write position.
parameter value
source · line 453value: UInt8
function ensureWritable
source · line 169public fun ensureWritable(count: Long): Unit
Grows storage when needed to provide at least count additional writable bytes, preserving positions and initialized content.
parameter count
source · line 169count: Long
function readInt64
source · line 430public fun readInt64(order: ByteOrder): Int64
Reads 8 bytes as Int64 in the selected byte order and advances the read position.
parameter order
source · line 430order: ByteOrder
function withWritableBytes
source · line 532@Unsafe
public fun withWritableBytes(block: (Ptr<Byte>?, Long) -> Long): Long
Borrows writable native storage for the callback, then advances the write position by the returned valid count.
parameter block
source · line 533block: (Ptr<Byte>?, Long) -> Long
function close
source · line 633public override fun close(): Unit
- Overrides
close
Releases native storage; an outstanding borrow prevents closure.
function borrowReadable
source · line 551@Unsafe
public fun borrowReadable(count: Long): NativeByteBorrow
Begins an explicit readable borrow of count bytes. Complete it once with the consumed count after native access ends.
parameter count
source · line 552count: Long
function readUInt32
source · line 426public fun readUInt32(order: ByteOrder): UInt32
Reads 4 bytes as UInt32 in the selected byte order and advances the read position.
parameter order
source · line 426order: ByteOrder
function readBytes
source · line 290public fun readBytes(count: Long): Array<Byte>
Copies count readable bytes into an independent array and advances the read position.
parameter count
source · line 290count: Long
function writeUInt32
source · line 481public fun writeUInt32(value: UInt32, order: ByteOrder): Unit
Appends 4 bytes representing UInt32 in the selected byte order and advances the write position.
parameter order
source · line 481order: ByteOrder
parameter value
source · line 481value: UInt32
function writeInt16
source · line 460public fun writeInt16(value: Int16, order: ByteOrder): Unit
Appends 2 bytes representing Int16 in the selected byte order and advances the write position.
parameter order
source · line 460order: ByteOrder
parameter value
source · line 460value: Int16
function writeInt32
source · line 474public fun writeInt32(value: Int32, order: ByteOrder): Unit
Appends 4 bytes representing Int32 in the selected byte order and advances the write position.
parameter value
source · line 474value: Int32
parameter order
source · line 474order: ByteOrder
function writeUInt16
source · line 467public fun writeUInt16(value: UInt16, order: ByteOrder): Unit
Appends 2 bytes representing UInt16 in the selected byte order and advances the write position.
parameter value
source · line 467value: UInt16
parameter order
source · line 467order: ByteOrder
function writeInt64
source · line 488public fun writeInt64(value: Int64, order: ByteOrder): Unit
Appends 8 bytes representing Int64 in the selected byte order and advances the write position.
parameter order
source · line 488order: ByteOrder
parameter value
source · line 488value: Int64
function readInto
source · line 310public fun readInto(array: MutableArray<Byte>, offset: Long = 0L, count: Long = array.size - offset): Unit
Copies exactly count readable bytes into the selected array region and advances the read position.
parameter array
source · line 311array: MutableArray<Byte>
parameter offset
source · line 312offset: Long = 0L
parameter count
source · line 313count: Long = array.size - offset
function writeDouble
source · line 509public fun writeDouble(value: Double, order: ByteOrder): Unit
Appends 8 bytes representing Double in the selected byte order and advances the write position.
parameter value
source · line 509value: Double
parameter order
source · line 509order: ByteOrder
function writeByte
source · line 283public fun writeByte(value: Byte): Unit
Appends one byte and advances the write position.
parameter value
source · line 283value: Byte
function readInt32
source · line 422public fun readInt32(order: ByteOrder): Int32
Reads 4 bytes as Int32 in the selected byte order and advances the read position.
parameter order
source · line 422order: ByteOrder
function skip
source · line 224public fun skip(count: Long): Unit
Advances the read position by count available bytes.
parameter count
source · line 224count: Long
function setByte
source · line 265public fun setByte(index: Long, value: Byte): Unit
Replaces an initialized byte at an absolute index without moving either position.
parameter index
source · line 265index: Long
parameter value
source · line 265value: Byte
function getByte
source · line 234public fun getByte(index: Long): Byte
Reads an initialized byte at an absolute index without moving either position.
parameter index
source · line 234index: Long
property writableBytes
source · line 72public val writableBytes: Long
get: public read-only
The remaining capacity after the write position.
getter get
source · line 72get(): Long
property readableBytes
source · line 64public val readableBytes: Long
get: public read-only
The byte count between read and write positions.
getter get
source · line 64get(): Long
function writeInt8
source · line 447public fun writeInt8(value: Int8): Unit
Appends 1 bytes representing Int8 and advances the write position.
parameter value
source · line 447value: Int8
function readInt16
source · line 414public fun readInt16(order: ByteOrder): Int16
Reads 2 bytes as Int16 in the selected byte order and advances the read position.
parameter order
source · line 414order: ByteOrder
property writePosition
source · line 56public val writePosition: Long
get: public read-only
The absolute offset immediately after initialized written bytes.
getter get
source · line 56get(): Long
function clear
source · line 195public fun clear(): Unit
Resets both positions to zero without promising to erase stored memory.
function readFloat
source · line 438public fun readFloat(order: ByteOrder): Float
Reads 4 bytes as Float in the selected byte order and advances the read position.
parameter order
source · line 438order: ByteOrder
function getBytes
source · line 247public fun getBytes(index: Long, count: Long): Array<Byte>
Copies an initialized absolute byte range without moving either position.
parameter index
source · line 247index: Long
parameter count
source · line 247count: Long
function borrowWritable
source · line 558@Unsafe
public fun borrowWritable(count: Long): NativeByteBorrow
Begins an explicit writable borrow of count bytes. Complete it once with the produced count after native access ends.
parameter count
source · line 559count: Long