• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // This file was automatically generated from formats.md by Knit tool. Do not edit.
2 package example.exampleFormats06
3 
4 import kotlinx.serialization.*
5 import kotlinx.serialization.protobuf.*
6 
<lambda>null7 fun ByteArray.toAsciiHexString() = joinToString("") {
8     if (it in 32..127) it.toInt().toChar().toString() else
9         "{${it.toUByte().toString(16).padStart(2, '0').uppercase()}}"
10 }
11 
12 @Serializable
13 class Data(
14     @ProtoType(ProtoIntegerType.DEFAULT)
15     val a: Int,
16     @ProtoType(ProtoIntegerType.SIGNED)
17     val b: Int,
18     @ProtoType(ProtoIntegerType.FIXED)
19     val c: Int
20 )
21 
mainnull22 fun main() {
23     val data = Data(1, -2, 3)
24     println(ProtoBuf.encodeToByteArray(data).toAsciiHexString())
25 }
26