Repository navigation
Commit 16e6da7
committed
feat: OpenEnum, Config::typed_enum_fields
Introduce OpenEnum to represent fields of Protobuf enumerated types
with the possibility of unknown values.
A new enum_type annotation is supported in the prost attribute
inside derives, which allows to specify the type-checked representation
of enum types in message fields and oneof variants.
The accepted values are "open" or "closed".
Use OpenEnum in generated code for enum-typed fields of messages
instead of i32, if the `enum_type` annotation is set to "open".
OpenEnum features get and set methods, which are meant to be
the primary ways to get and set open enumeration fields,
instead of the getters and setters generated by Message derive.
Add typed_enum_fields method to prost-build configuration, which
allows type-checked representation of enumerations in fields of
message structs and variants of oneof enums. The argument and the
invocation order works like with the boxed method.
Depending on the syntax (and preparing for the future support of
editions), the type-checked representation can be closed (for proto2)
or open (for proto3). The former is represented by the generated
enum type itself, while the latter is represented by OpenEnum
wrapping the enum type.1 parent 1e93f56 commit 16e6da7
16 files changed
Lines changed: 26540 additions & 414 deletions
File tree
- benchmarks/benches
- prost-build/src
- prost-derive/src/field
- prost/src
- tests
- src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
388 | 388 | | |
389 | 389 | | |
390 | 390 | | |
391 | | - | |
| 391 | + | |
392 | 392 | | |
393 | 393 | | |
394 | 394 | | |
| |||
415 | 415 | | |
416 | 416 | | |
417 | 417 | | |
418 | | - | |
419 | | - | |
420 | | - | |
421 | | - | |
422 | | - | |
423 | | - | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
424 | 428 | | |
425 | 429 | | |
426 | 430 | | |
| |||
537 | 541 | | |
538 | 542 | | |
539 | 543 | | |
540 | | - | |
| 544 | + | |
541 | 545 | | |
542 | 546 | | |
543 | 547 | | |
544 | | - | |
545 | 548 | | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
546 | 554 | | |
547 | 555 | | |
548 | 556 | | |
| |||
630 | 638 | | |
631 | 639 | | |
632 | 640 | | |
633 | | - | |
634 | | - | |
635 | | - | |
636 | | - | |
637 | | - | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
638 | 647 | | |
639 | 648 | | |
640 | 649 | | |
| |||
930 | 939 | | |
931 | 940 | | |
932 | 941 | | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
933 | 950 | | |
934 | 951 | | |
935 | 952 | | |
936 | 953 | | |
937 | 954 | | |
938 | 955 | | |
939 | | - | |
| 956 | + | |
940 | 957 | | |
941 | 958 | | |
942 | 959 | | |
| |||
946 | 963 | | |
947 | 964 | | |
948 | 965 | | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
949 | 975 | | |
950 | 976 | | |
951 | 977 | | |
| |||
987 | 1013 | | |
988 | 1014 | | |
989 | 1015 | | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
990 | 1034 | | |
991 | 1035 | | |
992 | 1036 | | |
| |||
1077 | 1121 | | |
1078 | 1122 | | |
1079 | 1123 | | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
1080 | 1130 | | |
1081 | 1131 | | |
1082 | 1132 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| |||
374 | 375 | | |
375 | 376 | | |
376 | 377 | | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
377 | 402 | | |
378 | 403 | | |
379 | 404 | | |
| |||
1179 | 1204 | | |
1180 | 1205 | | |
1181 | 1206 | | |
| 1207 | + | |
1182 | 1208 | | |
1183 | 1209 | | |
1184 | 1210 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
171 | 180 | | |
172 | 181 | | |
173 | 182 | | |
| |||
0 commit comments