@@ -108,7 +108,7 @@ A simple example:
108
108
``` proto
109
109
syntax = "proto3";
110
110
111
- package com. toasttab.protokt.sample;
111
+ package toasttab.protokt.sample;
112
112
113
113
message Sample {
114
114
string sample_field = 1;
@@ -120,7 +120,7 @@ will produce:
120
120
``` kotlin
121
121
/*
122
122
* Generated by protokt version <version>. Do not modify.
123
- * Source: com/ toasttab/protokt/sample/sample.proto
123
+ * Source: toasttab/protokt/sample/sample.proto
124
124
*/
125
125
126
126
package com.toasttab.protokt.sample
@@ -134,7 +134,7 @@ import com.toasttab.protokt.rt.Tag
134
134
import com.toasttab.protokt.rt.UnknownFieldSet
135
135
import com.toasttab.protokt.rt.sizeof
136
136
137
- @KtGeneratedMessage(" com. toasttab.protokt.sample.Sample" )
137
+ @KtGeneratedMessage(" toasttab.protokt.sample.Sample" )
138
138
class Sample
139
139
private constructor (
140
140
val sampleField: String ,
@@ -275,7 +275,7 @@ syntax = "proto3";
275
275
276
276
import "protokt/protokt.proto";
277
277
278
- package com. example;
278
+ package example;
279
279
280
280
option (protokt.file).kotlin_package = "com.package";
281
281
@@ -295,6 +295,8 @@ InputStream, or others.
295
295
296
296
#### Enums
297
297
298
+ ##### Representation
299
+
298
300
Protokt represents enum fields as sealed classes with an integer value and name.
299
301
Protobuf enums cannot be represented as Kotlin enum classes since Kotlin enum
300
302
classes are closed and cannot represent unknown values. The Protocol Buffers
@@ -327,6 +329,13 @@ sealed class PhoneType(
327
329
}
328
330
```
329
331
332
+ ##### Naming
333
+
334
+ To keep enums ergonomic while promoting protobuf best-practices, enums that have
335
+ all values
336
+ [ prefixed with the enum type name] ( https://developers.google.com/protocol-buffers/docs/style#enums )
337
+ will have that prefix stripped in their Kotlin representations.
338
+
330
339
#### Other Notes
331
340
332
341
- ` optimize_for ` is ignored.
@@ -336,6 +345,7 @@ sealed class PhoneType(
336
345
single property.
337
346
- ` bytes ` fields are wrapped in the protokt ` Bytes ` class to ensure immutability
338
347
akin to ` protobuf-java ` 's ` ByteString ` .
348
+ - Protokt implements proto3's ` optional ` .
339
349
340
350
### Extensions
341
351
0 commit comments