BufferHandleFactory

Factory and conversion utilities for creating BufferHandle instances from common Kotlin types and for slicing existing handles.

Functions

Link copied to clipboard
fun borrow(data: ByteArray, mutable: Boolean = false): BufferHandle.Borrowed

Borrow a ByteArray without copying. Caller must ensure the array outlives the handle.

fun borrow(data: ByteArray, offset: Int, length: Int, mutable: Boolean = false): BufferHandle.Borrowed

Borrow with offset and length.

Link copied to clipboard
fun fileBacked(path: String, offset: Long, size: Long): BufferHandle.FileBacked

Create a file-backed handle (metadata only — actual mapping is platform-specific).

Link copied to clipboard

Create an BufferHandle.Owned by copying a ByteArray.

Create an BufferHandle.Owned from a FloatArray (copies to little-endian bytes).

Create an BufferHandle.Owned from an IntArray (copies to little-endian bytes).

Link copied to clipboard
fun slice(parent: BufferHandle, byteOffset: Long, sizeInBytes: Long): BufferHandle.Aliased

Create an aliased slice of an existing handle.