LengthFrom

annotation class LengthFrom(val field: String)

Marks a String field whose byte length is determined by a preceding numeric field. The referenced field must exist, come before this field, and be a numeric type.

@ProtocolMessage
data class NamedRecord(
val nameLength: UShort,
@LengthFrom("nameLength") val name: String, // reads nameLength bytes as UTF-8
val value: Int,
)

Parameters

field

The name of the preceding numeric field that holds the byte length.

Properties

Link copied to clipboard