Package-level declarations

Types

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.CLASS])
annotation class DispatchOn(val type: KClass<*>)

Specifies a custom discriminator type for a @ProtocolMessage sealed interface.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.PROPERTY])
annotation class DispatchValue

Marks a property as the dispatch value within a @DispatchOn discriminator type.

Link copied to clipboard
Link copied to clipboard
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.

Link copied to clipboard

Length prefix encoding for LengthPrefixed fields. All variants use big-endian (network) byte order.

Link copied to clipboard
annotation class LengthPrefixed(val prefix: LengthPrefix = LengthPrefix.Short)

Marks a String or payload field as length-prefixed: prefix bytes followed by UTF-8 data. Default is 2-byte big-endian (UShort) prefix.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.CLASS])
annotation class PacketType(val value: Int, val wire: Int = -1)

Specifies the discriminator value for a variant of a @ProtocolMessage sealed interface.

Link copied to clipboard
annotation class Payload

Marks a type parameter as the application payload. The generated codec will provide a scoped PayloadReader for decoding.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.CLASS])
annotation class ProtocolMessage(val wireOrder: Endianness = Endianness.Default)

Marks a data class or sealed interface as a protocol message. KSP will generate a Codec implementation for this type at compile time.

Link copied to clipboard
annotation class RemainingBytes

Marks a String field to consume all remaining bytes as UTF-8. Must be the last non-conditional field in the constructor.

Link copied to clipboard
annotation class UseCodec(val codec: KClass<*>)

Delegates field decoding/encoding to an existing Codec object.

Link copied to clipboard
annotation class WhenTrue(val expression: String)

Conditional field: only present on the wire when the referenced expression is true. The field must be nullable with a default value of null.

Link copied to clipboard
annotation class WireBytes(val value: Int)

Overrides the wire width of a numeric field. The value specifies the number of bytes on the wire (1-8). Must not exceed the Kotlin type's natural size. Cannot be used on Float, Double, or Boolean.

Link copied to clipboard
annotation class WireOrder(val order: Endianness)

Overrides the byte order for a single field, taking precedence over ProtocolMessage.wireOrder. Use when a protocol mixes byte orders within a single message (e.g., big-endian magic + little-endian lengths).