CustomFieldDescriptor

data class CustomFieldDescriptor(val readFunction: FunctionRef, val writeFunction: FunctionRef, val fixedSize: Int = -1, val sizeOfFunction: FunctionRef? = null, val contextFields: List<String> = emptyList())

Describes a custom field strategy via function references.

Read function: ReadBuffer extension, takes optional context args, returns field type. Generated: buffer.readFoo(contextArg1, contextArg2)

Write function: WriteBuffer extension, takes field value + optional context args. Generated: buffer.writeFoo(value.fieldName, value.contextArg1)

SizeOf function: standalone, takes field value, returns Int. Generated: fooSize(value.fieldName)

Constructors

Link copied to clipboard
constructor(readFunction: FunctionRef, writeFunction: FunctionRef, fixedSize: Int = -1, sizeOfFunction: FunctionRef? = null, contextFields: List<String> = emptyList())

Properties

Link copied to clipboard

Previously decoded field names to pass as extra arguments to read/write functions

Link copied to clipboard

Fixed byte size if known at compile time, or -1 for variable-length

Link copied to clipboard

ReadBuffer extension function to call for decoding

Link copied to clipboard

Standalone function(fieldValue) -> Int for runtime size. null = skip sizeOf

Link copied to clipboard

WriteBuffer extension function to call for encoding