CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-com-squareup-wire--wire-runtime

Runtime support library for Wire-generated Protocol Buffer classes in Kotlin multiplatform applications

Pending
Overview
Eval results
Files

field-annotations.mddocs/

Field Annotations

Annotations for marking generated message fields with encoding metadata and serialization behavior. These annotations control how Wire generates code and how fields are handled during encoding and decoding.

Capabilities

WireField Annotation

Primary annotation for protocol buffer field metadata used by Wire's code generator.

/**
 * Annotates generated Message fields with metadata for serialization and deserialization
 */
@Target(AnnotationTarget.FIELD)
@Retention(AnnotationRetention.RUNTIME)
annotation class WireField(
    /** The tag number used to store the field's value */
    val tag: Int,
    
    /** Reference to ProtoAdapter for keys (maps only) */
    val keyAdapter: String = "",
    
    /** Reference to ProtoAdapter for values */
    val adapter: String,
    
    /** Field label (OPTIONAL, REQUIRED, REPEATED, etc.) */
    val label: Label = Label.OPTIONAL,
    
    /** Redacted fields omitted from toString() */
    val redacted: Boolean = false,
    
    /** Original proto field name if different from generated */
    val declaredName: String = "",
    
    /** JSON field name if different from proto name */
    val jsonName: String = "",
    
    /** Oneof group name if field is part of oneof */
    val oneofName: String = "",
    
    /** Declaration order in proto schema */
    val schemaIndex: Int = -1
)

Field Labels

Enum defining the protocol buffer field behavior and encoding rules.

enum class Label {
    /** Required field (proto2 only) */
    REQUIRED,
    
    /** Optional field (default) */
    OPTIONAL,
    
    /** Repeated field */
    REPEATED,
    
    /** Oneof field */
    ONE_OF,
    
    /** Packed repeated field (more efficient for primitives) */
    PACKED,
    
    /** Proto3 field omitted if identity value */
    OMIT_IDENTITY;
    
    /** True if field is repeated */
    val isRepeated: Boolean
    
    /** True if field uses packed encoding */
    val isPacked: Boolean
    
    /** True if field is part of oneof */
    val isOneOf: Boolean
}

Usage Examples:

// Generated message class with field annotations
class Person(
    @field:WireField(
        tag = 1,
        adapter = "com.squareup.wire.ProtoAdapter#STRING"
    )
    val name: String,
    
    @field:WireField(
        tag = 2,
        adapter = "com.squareup.wire.ProtoAdapter#INT32",
        label = WireField.Label.OPTIONAL
    )
    val age: Int,
    
    @field:WireField(
        tag = 3,
        adapter = "com.squareup.wire.ProtoAdapter#STRING",
        label = WireField.Label.REPEATED
    )
    val emails: List<String>,
    
    @field:WireField(
        tag = 4,
        adapter = "com.example.AddressAdapter#ADAPTER"
    )
    val address: Address?,
    
    unknownFields: ByteString = ByteString.EMPTY
) : Message<Person, Person.Builder>(ADAPTER, unknownFields)

Other Annotations

Additional annotations for specialized use cases.

/** Annotation for enum constants */
@Target(AnnotationTarget.FIELD)
@Retention(AnnotationRetention.RUNTIME)
annotation class WireEnumConstant(
    val declaredName: String = ""
)

/** Annotation for RPC methods */
@Target(AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.RUNTIME) 
annotation class WireRpc(
    val path: String,
    val requestAdapter: String,
    val responseAdapter: String
)

Install with Tessl CLI

npx tessl i tessl/maven-com-squareup-wire--wire-runtime

docs

any-message.md

enum-support.md

field-annotations.md

index.md

message-framework.md

proto-adapters.md

protobuf-io.md

time-types.md

tile.json