Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewparmet committed Oct 7, 2020
1 parent 16e8d67 commit d1f2510
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ A simple example:
```proto
syntax = "proto3";
package com.toasttab.protokt.sample;
package toasttab.protokt.sample;
message Sample {
string sample_field = 1;
Expand All @@ -120,7 +120,7 @@ will produce:
```kotlin
/*
* Generated by protokt version <version>. Do not modify.
* Source: com/toasttab/protokt/sample/sample.proto
* Source: toasttab/protokt/sample/sample.proto
*/

package com.toasttab.protokt.sample
Expand All @@ -134,7 +134,7 @@ import com.toasttab.protokt.rt.Tag
import com.toasttab.protokt.rt.UnknownFieldSet
import com.toasttab.protokt.rt.sizeof

@KtGeneratedMessage("com.toasttab.protokt.sample.Sample")
@KtGeneratedMessage("toasttab.protokt.sample.Sample")
class Sample
private constructor(
val sampleField: String,
Expand Down Expand Up @@ -275,7 +275,7 @@ syntax = "proto3";
import "protokt/protokt.proto";
package com.example;
package example;
option (protokt.file).kotlin_package = "com.package";
Expand All @@ -295,6 +295,8 @@ InputStream, or others.

#### Enums

##### Representation

Protokt represents enum fields as sealed classes with an integer value and name.
Protobuf enums cannot be represented as Kotlin enum classes since Kotlin enum
classes are closed and cannot represent unknown values. The Protocol Buffers
Expand Down Expand Up @@ -327,6 +329,13 @@ sealed class PhoneType(
}
```

##### Naming

To keep enums ergonomic while promoting protobuf best-practices, enums that have
all values
[prefixed with the enum type name](https://developers.google.com/protocol-buffers/docs/style#enums)
will have that prefix stripped in their Kotlin representations.

#### Other Notes

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

### Extensions

Expand Down

0 comments on commit d1f2510

Please sign in to comment.