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
@Target(allowedTargets = [AnnotationTarget.CLASS])
annotation class ForwardCompatible(val unknown: KClass<*>)

Marks a @ProtocolMessage sealed dispatch parent as forward compatible: a decoder that hits a discriminator it does not recognize skips the unknown variant's framed payload and preserves it verbatim into the unknown variant, instead of throwing DecodeException.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.CLASS])
annotation class FramedBy(val codec: KClass<out BoundingLengthCodec<UInt>>, val after: String = "")

Marks a @ProtocolMessage class (typically a sealed parent) with a framing length prefix that is computed from — and bounds — the body's wire size.

Link copied to clipboard
annotation class LengthFrom(val field: String)

Marks a field whose byte length is determined by a numeric sibling elsewhere in the message — the length is carried as a separate constructor parameter because the consumer cares about it as a number (flow control, routing) or because the on-wire prefix shape is one @LengthPrefixed cannot express (e.g. TLS uint24).

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 length-prefixed field: prefix bytes carrying the value's wire size, followed by the value's bytes. Default prefix width is 2-byte big-endian (UShort).

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
@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 field that consumes the remaining bytes of the bounded buffer.

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

Marks the single sealed-variant sink that a ForwardCompatible union skips unknown discriminators into. The marked variant must not carry PacketType — it is the else arm of dispatch, never matched by value — and its primary constructor must be (opcode: Int, raw: PlatformBuffer) (a ReadBuffer-typed raw is also accepted). For a varint discriminator the opcode parameter is instead the discriminator's own inner type (Long / ULong), carrying the full decoded type value — see ForwardCompatible requirement 3.

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 When(val predicate: String)

Conditional field: only present on the wire when the predicate holds. The field must be nullable. Setting = null as the constructor default is conventional (so the data class can be constructed without naming the field when the predicate is false) but is not enforced — KSP cannot inspect default expression trees, so any rule the validator can't actually check is not part of the contract.

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).