Skip to content

Commit 96c7edd

Browse files
Protocol Buffer TeamLogofile
Protocol Buffer Team
authored andcommitted
Project import generated by Copybara.
PiperOrigin-RevId: 744747856 Change-Id: Ibe9d1e30b313da5b3130fb2806d706147587e4ff
1 parent 1c34706 commit 96c7edd

File tree

8 files changed

+69
-78
lines changed

8 files changed

+69
-78
lines changed

content/getting-started/pythontutorial.md

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,16 @@ each field in the message. Here is the `.proto` file that defines your messages,
7676
`addressbook.proto`.
7777

7878
```proto
79-
syntax = "proto2";
79+
edition = "2023";
8080
8181
package tutorial;
8282
83+
option features.field_presence = EXPLICIT;
84+
8385
message Person {
84-
optional string name = 1;
85-
optional int32 id = 2;
86-
optional string email = 3;
86+
string name = 1;
87+
int32 id = 2;
88+
string email = 3;
8789
8890
enum PhoneType {
8991
PHONE_TYPE_UNSPECIFIED = 0;
@@ -93,8 +95,8 @@ message Person {
9395
}
9496
9597
message PhoneNumber {
96-
optional string number = 1;
97-
optional PhoneType type = 2 [default = PHONE_TYPE_HOME];
98+
string number = 1;
99+
PhoneType type = 2 [default = PHONE_TYPE_HOME];
98100
}
99101
100102
repeated PhoneNumber phones = 4;
@@ -135,39 +137,9 @@ less-commonly used optional elements. Each element in a repeated field requires
135137
re-encoding the tag number, so repeated fields are particularly good candidates
136138
for this optimization.
137139

138-
Each field must be annotated with one of the following modifiers:
139-
140-
- `optional`: the field may or may not be set. If an optional field value
141-
isn't set, a default value is used. For simple types, you can specify your
142-
own default value, as we've done for the phone number `type` in the example.
143-
Otherwise, a system default is used: zero for numeric types, the empty
144-
string for strings, false for bools. For embedded messages, the default
145-
value is always the "default instance" or "prototype" of the message, which
146-
has none of its fields set. Calling the accessor to get the value of an
147-
optional (or required) field which has not been explicitly set always
148-
returns that field's default value.
149-
- `repeated`: the field may be repeated any number of times (including zero).
150-
The order of the repeated values will be preserved in the protocol buffer.
151-
Think of repeated fields as dynamically sized arrays.
152-
- `required`: a value for the field must be provided, otherwise the message
153-
will be considered "uninitialized". Serializing an uninitialized message
154-
will raise an exception. Parsing an uninitialized message will fail. Other
155-
than this, a required field behaves exactly like an optional field.
156-
157-
{{% alert title="Important" color="warning" %}} **Required Is Forever**
158-
You should be very careful about marking fields as `required`. If at some point
159-
you wish to stop writing or sending a required field, it will be problematic to
160-
change the field to an optional field -- old readers will consider messages
161-
without this field to be incomplete and may reject or drop them unintentionally.
162-
You should consider writing application-specific custom validation routines for
163-
your buffers instead. Within Google, `required` fields are strongly disfavored;
164-
most messages defined in proto2 syntax use `optional` and `repeated` only.
165-
(Proto3 does not support `required` fields at all.)
166-
{{% /alert %}}
167-
168140
You'll find a complete guide to writing `.proto` files -- including all the
169141
possible field types -- in the
170-
[Protocol Buffer Language Guide](/programming-guides/proto2).
142+
[Protocol Buffer Language Guide](/programming-guides/editions).
171143
Don't go looking for facilities similar to class inheritance, though -- protocol
172144
buffers don't do that.
173145

content/installation.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ binaries, follow these instructions:
2323

2424
```sh
2525
PB_REL="https://github.com/protocolbuffers/protobuf/releases"
26-
curl -LO $PB_REL/download/v< param protoc-version >/protoc-< param protoc-version >-linux-x86_64.zip
26+
curl -LO $PB_REL/download/v30.2/protoc-30.2-linux-x86_64.zip
27+
2728
```
2829

2930
2. Unzip the file under `$HOME/.local` or a directory of your choice. For
3031
example:
3132

3233
```sh
33-
unzip protoc-< param protoc-version >-linux-x86_64.zip -d $HOME/.local
34+
unzip protoc-30.2-linux-x86_64.zip -d $HOME/.local
3435
```
3536

3637
3. Update your environment's path variable to include the path to the `protoc`

content/programming-guides/editions.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,11 @@ following rules:
10031003
effect as if you had cast the number to that type in C++ (for example, if a
10041004
64-bit number is read as an int32, it will be truncated to 32 bits).
10051005
* `sint32` and `sint64` are compatible with each other but are *not*
1006-
compatible with the other integer types.
1006+
compatible with the other integer types. If the value written was between
1007+
INT_MIN and INT_MAX inclusive it will parse as the same value with either
1008+
type. If an sint64 value was written outside of that range and parsed as an
1009+
sint32, the varint is truncated to 32 bits and then zigzag decoding occurs
1010+
(which will cause a different value to be observed).
10071011
* `string` and `bytes` are compatible as long as the bytes are valid UTF-8.
10081012
* Embedded messages are compatible with `bytes` if the bytes contain an
10091013
encoded instance of the message.

content/programming-guides/proto2.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,11 @@ following rules:
10561056
effect as if you had cast the number to that type in C++ (for example, if a
10571057
64-bit number is read as an int32, it will be truncated to 32 bits).
10581058
* `sint32` and `sint64` are compatible with each other but are *not*
1059-
compatible with the other integer types.
1059+
compatible with the other integer types. If the value written was between
1060+
INT_MIN and INT_MAX inclusive it will parse as the same value with either
1061+
type. If an sint64 value was written outside of that range and parsed as an
1062+
sint32, the varint is truncated to 32 bits and then zigzag decoding occurs
1063+
(which will cause a different value to be observed).
10601064
* `string` and `bytes` are compatible as long as the bytes are valid UTF-8.
10611065
* Embedded messages are compatible with `bytes` if the bytes contain an
10621066
encoded instance of the message.

content/programming-guides/proto3.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -879,9 +879,14 @@ Instead of moving the `.proto` file directly and updating all the call sites in
879879
a single change, you can put a placeholder `.proto` file in the old location to
880880
forward all the imports to the new location using the `import public` notion.
881881

882-
**Note that the public import functionality is not available in Java, Kotlin,
883-
TypeScript, JavaScript, GCL, as well as C++ targets that use protobuf static
884-
reflection.**
882+
**Note:** The public import functionality available in Java is most effective
883+
when moving an entire .proto file or when using `java_multiple_files = true`. In
884+
these cases, generated names remain stable, avoiding the need to update
885+
references in your code. While technically functional when moving a subset of a
886+
.proto file without `java_multiple_files = true`, doing so requires simultaneous
887+
updates to many references, thus might not significantly ease migration. The
888+
functionality is not available in Kotlin, TypeScript, JavaScript, GCL, or with
889+
C++ targets that use protobuf static reflection.
885890

886891
`import public` dependencies can be transitively relied upon by any code
887892
importing the proto containing the `import public` statement. For example:
@@ -1006,7 +1011,11 @@ following rules:
10061011
effect as if you had cast the number to that type in C++ (for example, if a
10071012
64-bit number is read as an int32, it will be truncated to 32 bits).
10081013
* `sint32` and `sint64` are compatible with each other but are *not*
1009-
compatible with the other integer types.
1014+
compatible with the other integer types. If the value written was between
1015+
INT_MIN and INT_MAX inclusive it will parse as the same value with either
1016+
type. If an sint64 value was written outside of that range and parsed as an
1017+
sint32, the varint is truncated to 32 bits and then zigzag decoding occurs
1018+
(which will cause a different value to be observed).
10101019
* `string` and `bytes` are compatible as long as the bytes are valid UTF-8.
10111020
* Embedded messages are compatible with `bytes` if the bytes contain an
10121021
encoded instance of the message.

content/reference/protobuf/textformat-spec.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,12 @@ escape = "\a" (* ASCII #7 (bell) *)
171171

172172
Octal escape sequences consume up to three octal digits. Additional digits are
173173
passed through without escaping. For example, when unescaping the input `\1234`,
174-
the parser consumes three octal digits (123) to unescape the byte value 0x83
175-
(ASCII 'S') and the subsequent '4' passes through as the byte value 0x34 (ASCII
176-
'4'). To ensure correct parsing, express octal escape sequences with 3 octal
177-
digits, using leading zeros as needed, such as: `\000`, `\001`, `\063`, `\377`.
178-
Fewer than three digits are consumed when a non-numeric character follows the
179-
numeric characters, such as `\5Hello`.
174+
the parser consumes three octal digits (123) to unescape the byte value 0x53
175+
(ASCII 'S', 83 in decimal) and the subsequent '4' passes through as the byte
176+
value 0x34 (ASCII '4'). To ensure correct parsing, express octal escape
177+
sequences with 3 octal digits, using leading zeros as needed, such as: `\000`,
178+
`\001`, `\063`, `\377`. Fewer than three digits are consumed when a non-numeric
179+
character follows the numeric characters, such as `\5Hello`.
180180

181181
Hexadecimal escape sequences consume up to two hexadecimal digits. For example,
182182
when unescaping `\x213`, the parser consumes only the first two digits (21) to

content/support/cross-version-runtime-guarantee.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ using the generated code. When these come from different releases of protobuf,
1313
we are in a "cross version runtime" situation.
1414

1515
We intend to offer the following guarantees across all languages except
16-
[C++](#cpp). These are the default guarantees; however, owners of protobuf code
17-
generators and runtimes may explicitly override them with more specific
18-
guarantees for that language.
16+
[C++ and Rust](#cpp). These are the default guarantees; however, owners of
17+
protobuf code generators and runtimes may explicitly override them with more
18+
specific guarantees for that language.
1919

2020
Protobuf cross-version usages outside the guarantees are **error-prone and not
2121
supported**. Version skews can lead to *flakes and undefined behaviors* that are
@@ -120,9 +120,10 @@ matrix:
120120

121121
Coexistence of multiple major versions in the same process is **not** supported.
122122

123-
## C++ Specific Guarantees {#cpp}
123+
## C++ and Rust Specific Guarantees {#cpp}
124+
125+
Protobuf C++ and Rust disclaim all cross-runtime support and require an exact
126+
match between the generated code version and the runtime version at all times.
124127

125-
Protobuf C++ disclaims all cross-runtime support and requires an exact match
126-
between its generated code version and its runtime version at all times.
127128
Additionally, Protobuf C++ makes no guarantees about ABI stability across any
128129
releases (major, minor, or micro).

content/support/version-support.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ Future plans are shown in *italics* and are subject to change.
121121
<td>25 May 2022</td>
122122
<td>31 Mar 2024</td>
123123
</tr>
124-
<tr class="maintenance">
124+
<tr class="end-of-life">
125125
<th>4.x</th>
126126
<td>16 Feb 2023</td>
127127
<td>31 Mar 2025</td>
@@ -178,7 +178,7 @@ Future plans are shown in *italics* and are subject to change.
178178
<td class="y25q3"></td>
179179
<td class="y25q4"></td>
180180
</tr>
181-
<tr class="maintenance">
181+
<tr class="end-of-life">
182182
<th>4.x</th>
183183
<td>22.x-25.x</td>
184184
<td class="y23q1 active">4.22</td>
@@ -194,7 +194,7 @@ Future plans are shown in *italics* and are subject to change.
194194
<td class="y25q3"></td>
195195
<td class="y25q4"></td>
196196
</tr>
197-
<tr class="active">
197+
<tr class="maintenance">
198198
<th>5.x</th>
199199
<td>26.x-29.x</td>
200200
<td class="y23q1"></td>
@@ -210,7 +210,7 @@ Future plans are shown in *italics* and are subject to change.
210210
<td class="y25q3 maintenance">5.29</td>
211211
<td class="y25q4 maintenance">5.29</td>
212212
</tr>
213-
<tr class="future">
213+
<tr class="active">
214214
<th>6.x</th>
215215
<td>30.x-33.x</td>
216216
<td class="y23q1"></td>
@@ -365,28 +365,28 @@ Future plans are shown in *italics* and are subject to change.
365365
<tr class="maintenance">
366366
<th>3.x</th>
367367
<td>16 Feb 2023</td>
368-
<td>31 Mar 2026*</td>
368+
<td>31 Mar 2027*</td>
369369
</tr>
370370
<tr class="active">
371371
<th>4.x</th>
372372
<td>13 Mar 2024</td>
373-
<td>31 Mar 2027</td>
373+
<td>31 Mar 2028</td>
374374
</tr>
375375
<tr class="future">
376376
<th>5.x</th>
377-
<td>Q1 2026*</td>
378-
<td>31 Mar 2028</td>
377+
<td>Q1 2027*</td>
378+
<td>31 Mar 2029</td>
379379
</tr>
380380
</table>
381381

382382
{{% alert title="Note" color="note" %}}
383-
The maintenance support window for the Protobuf Java 3.x release will be 24
383+
The maintenance support window for the Protobuf Java 3.x release will be 36
384384
months rather than the typical 12 months for the final release in a major
385-
version line. Future major version updates (5.x, planned for Q1 2026) will adopt
385+
version line. Future major version updates (5.x, planned for Q1 2027) will adopt
386386
an improved
387387
["rolling compatibility window"](/support/cross-version-runtime-guarantee/#major)
388388
that should allow a return to 12-month support windows. There will be no major
389-
version bump in Q1 2025.{{% /alert %}}
389+
version bumps in Q1 2025 and Q1 2026.{{% /alert %}}
390390

391391
**Release support chart**
392392

@@ -522,7 +522,7 @@ Future plans are shown in *italics* and are subject to change.
522522
<th class="y25q3"><span>25Q3</span></th>
523523
<th class="y25q4"><span>25Q4</span></th>
524524
</tr>
525-
<tr class="active">
525+
<tr class="maintenance">
526526
<th>3.x</th>
527527
<td>22.x-29.x</td>
528528
<td class="y23q1 active">3.22</td>
@@ -538,7 +538,7 @@ Future plans are shown in *italics* and are subject to change.
538538
<td class="y25q3 maintenance">3.29</td>
539539
<td class="y25q4 maintenance">3.29</td>
540540
</tr>
541-
<tr class="future">
541+
<tr class="active">
542542
<th>4.x</th>
543543
<td>30.x+</td>
544544
<td class="y23q1"></td>
@@ -592,7 +592,7 @@ Future plans are shown in *italics* and are subject to change.
592592
<th>Release date</th>
593593
<th>End of support</th>
594594
</tr>
595-
<tr class="maintenance">
595+
<tr class="end-of-life">
596596
<th>3.x</th>
597597
<td>16 Feb 2023</td>
598598
<td>31 Mar 2025</td>
@@ -623,7 +623,7 @@ Future plans are shown in *italics* and are subject to change.
623623
<th class="y25q3"><span>25Q3</span></th>
624624
<th class="y25q4"><span>25Q4</span></th>
625625
</tr>
626-
<tr class="maintenance">
626+
<tr class="end-of-life">
627627
<th>3.x</th>
628628
<td>22.x-25.x</td>
629629
<td class="y23q1 active">3.22</td>
@@ -701,7 +701,7 @@ Future plans are shown in *italics* and are subject to change.
701701
<th>Release date</th>
702702
<th>End of support</th>
703703
</tr>
704-
<tr class="maintenance">
704+
<tr class="end-of-life">
705705
<th>4.x</th>
706706
<td>16 Feb 2023</td>
707707
<td>31 Mar 2025</td>
@@ -737,7 +737,7 @@ Future plans are shown in *italics* and are subject to change.
737737
<th class="y25q3"><span>25Q3</span></th>
738738
<th class="y25q4"><span>25Q4</span></th>
739739
</tr>
740-
<tr class="maintenance">
740+
<tr class="end-of-life">
741741
<th>4.x</th>
742742
<td>22.x-25.x</td>
743743
<td class="y23q1 active">4.22</td>
@@ -753,7 +753,7 @@ Future plans are shown in *italics* and are subject to change.
753753
<td class="y25q3"></td>
754754
<td class="y25q4"></td>
755755
</tr>
756-
<tr class="active">
756+
<tr class="maintenance">
757757
<th>5.x</th>
758758
<td>26.x-29.x</td>
759759
<td class="y23q1"></td>
@@ -769,7 +769,7 @@ Future plans are shown in *italics* and are subject to change.
769769
<td class="y25q3 maintenance">5.29</td>
770770
<td class="y25q4 maintenance">5.29</td>
771771
</tr>
772-
<tr class="future">
772+
<tr class="active">
773773
<th>6.x</th>
774774
<td>30.x+</td>
775775
<td class="y23q1"></td>
@@ -831,7 +831,7 @@ Future plans are shown in *italics* and are subject to change.
831831
<th>Release date</th>
832832
<th>End of support</th>
833833
</tr>
834-
<tr class="maintenance">
834+
<tr class="end-of-life">
835835
<th>3.x</th>
836836
<td>16 Feb 2023</td>
837837
<td>31 Mar 2025</td>
@@ -862,7 +862,7 @@ Future plans are shown in *italics* and are subject to change.
862862
<th class="y25q3"><span>25Q3</span></th>
863863
<th class="y25q4"><span>25Q4</span></th>
864864
</tr>
865-
<tr class="maintenance">
865+
<tr class="end-of-life">
866866
<th>3.x</th>
867867
<td>22.x-25.x</td>
868868
<td class="y23q1 active">3.22</td>

0 commit comments

Comments
 (0)