Skip to content

Commit d1f2510

Browse files
committed
update readme
1 parent 16e8d67 commit d1f2510

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

README.md

+14-4
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ A simple example:
108108
```proto
109109
syntax = "proto3";
110110
111-
package com.toasttab.protokt.sample;
111+
package toasttab.protokt.sample;
112112
113113
message Sample {
114114
string sample_field = 1;
@@ -120,7 +120,7 @@ will produce:
120120
```kotlin
121121
/*
122122
* Generated by protokt version <version>. Do not modify.
123-
* Source: com/toasttab/protokt/sample/sample.proto
123+
* Source: toasttab/protokt/sample/sample.proto
124124
*/
125125

126126
package com.toasttab.protokt.sample
@@ -134,7 +134,7 @@ import com.toasttab.protokt.rt.Tag
134134
import com.toasttab.protokt.rt.UnknownFieldSet
135135
import com.toasttab.protokt.rt.sizeof
136136

137-
@KtGeneratedMessage("com.toasttab.protokt.sample.Sample")
137+
@KtGeneratedMessage("toasttab.protokt.sample.Sample")
138138
class Sample
139139
private constructor(
140140
val sampleField: String,
@@ -275,7 +275,7 @@ syntax = "proto3";
275275
276276
import "protokt/protokt.proto";
277277
278-
package com.example;
278+
package example;
279279
280280
option (protokt.file).kotlin_package = "com.package";
281281
@@ -295,6 +295,8 @@ InputStream, or others.
295295

296296
#### Enums
297297

298+
##### Representation
299+
298300
Protokt represents enum fields as sealed classes with an integer value and name.
299301
Protobuf enums cannot be represented as Kotlin enum classes since Kotlin enum
300302
classes are closed and cannot represent unknown values. The Protocol Buffers
@@ -327,6 +329,13 @@ sealed class PhoneType(
327329
}
328330
```
329331

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+
330339
#### Other Notes
331340

332341
- `optimize_for` is ignored.
@@ -336,6 +345,7 @@ sealed class PhoneType(
336345
single property.
337346
- `bytes` fields are wrapped in the protokt `Bytes` class to ensure immutability
338347
akin to `protobuf-java`'s `ByteString`.
348+
- Protokt implements proto3's `optional`.
339349

340350
### Extensions
341351

0 commit comments

Comments
 (0)