1 /* 2 * Copyright 2017-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. 3 */ 4 5 package kotlinx.serialization.protobuf 6 7 import kotlinx.serialization.* 8 import kotlinx.serialization.descriptors.* 9 10 /** 11 * Specifies protobuf field number (a unique number for a field in the protobuf message) 12 * assigned to a Kotlin property. 13 * 14 * See [Assigning field numbers](https://protobuf.dev/programming-guides/proto2/#assigning) for details. 15 */ 16 @SerialInfo 17 @Target(AnnotationTarget.PROPERTY) 18 @ExperimentalSerializationApi 19 public annotation class ProtoNumber(public val number: Int) 20 21 /** 22 * Represents a number format in protobuf encoding set by [ProtoType] annotation. 23 * 24 * [DEFAULT] is default varint encoding (intXX), 25 * [SIGNED] is signed ZigZag representation (sintXX), and 26 * [FIXED] is fixedXX type. 27 * uintXX and sfixedXX are not supported yet. 28 * 29 * See [Scalar value types](https://protobuf.dev/programming-guides/proto2/#scalar) for details. 30 */ 31 @Suppress("NO_EXPLICIT_VISIBILITY_IN_API_MODE_WARNING") 32 @ExperimentalSerializationApi 33 public enum class ProtoIntegerType(internal val signature: Long) { 34 DEFAULT(0L shl 33), 35 SIGNED(1L shl 33), 36 FIXED(2L shl 33); 37 } 38 39 /** 40 * Instructs to use a particular [ProtoIntegerType] for a property of integer number type. 41 * Affect [Byte], [Short], [Int], [Long] and [Char] properties and does not affect others. 42 */ 43 @SerialInfo 44 @Target(AnnotationTarget.PROPERTY) 45 @ExperimentalSerializationApi 46 public annotation class ProtoType(public val type: ProtoIntegerType) 47 48 49 /** 50 * Instructs that a particular collection should be written as a [packed array](https://protobuf.dev/programming-guides/encoding/#packed). 51 */ 52 @SerialInfo 53 @Target(AnnotationTarget.PROPERTY) 54 @ExperimentalSerializationApi 55 public annotation class ProtoPacked 56