Skip to content

Commit 04a5488

Browse files
Update rust-generated corresponding to latest changes.
PiperOrigin-RevId: 914274603
1 parent 5933e44 commit 04a5488

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

content/reference/rust/rust-generated.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ directly).
8787
Failure reasons include if the representation exceeds the maximum encoded
8888
message size (must be less than 2 GiB), and `required` fields (proto2) that
8989
are unset.
90+
* `fn serialized_len(&self) -> usize`: Returns the size in bytes of the
91+
serialized message.
9092
* `fn take_from(&mut self, other)`: Moves `other` into `self`, discarding any
9193
previous state that `self` contained.
9294
* `fn copy_from(&mut self, other)`: Copies `other` into `self`, discarding any
@@ -96,6 +98,10 @@ directly).
9698
`Foo`. This is further covered in the section on proxy types.
9799
* `fn as_mut(&mut self) -> FooMut<'_>`: Returns a mutable handle (mut) to
98100
`Foo`. This is further covered in the section on proxy types.
101+
* `fn into_view(self) -> FooView<'_>`: Consumes `self` and returns an
102+
immutable handle (view) to `Foo` with a shorter lifetime.
103+
* `fn into_mut(self) -> FooMut<'_>`: Consumes `self` and returns a mutable
104+
handle (mut) to `Foo` with a shorter lifetime.
99105

100106
`Foo` additionally implements the following std traits:
101107

@@ -225,10 +231,8 @@ The compiler generates the following accessor methods:
225231
* `fn has_foo(&self) -> bool`: Returns `true` if the field is set.
226232
* `fn foo(&self) -> i32`: Returns the current value of the field. If the field
227233
is not set, it returns the default value.
228-
* `fn foo_opt(&self) -> protobuf::Optional<i32>`: Returns an optional with the
229-
variant `Set(value)` if the field is set or `Unset(default value)` if it's
230-
unset. See
231-
[`Optional` rustdoc](https://docs.rs/protobuf/4.33.5-release/protobuf/enum.Optional.html)
234+
* `fn foo_opt(&self) -> std::option::Option<i32>`: Returns `Some(value)` if
235+
the field is set or `None` if it's unset.
232236
* `fn set_foo(&mut self, val: i32)`: Sets the value of the field. After
233237
calling this, `has_foo()` will return `true` and `foo()` will return
234238
`value`.
@@ -255,9 +259,8 @@ The compiler generates the following accessor methods:
255259
* `fn foo(&self) -> &protobuf::ProtoStr`: Returns the current value of the
256260
field. If the field is not set, it returns the default value. See
257261
[`ProtoStr` rustdoc](https://docs.rs/protobuf/4.33.5-release/protobuf/struct.ProtoStr.html).
258-
* `fn foo_opt(&self) -> protobuf::Optional<&ProtoStr>`: Returns an optional
259-
with the variant `Set(value)` if the field is set or `Unset(default value)`
260-
if it's unset.
262+
* `fn foo_opt(&self) -> std::option::Option<&ProtoStr>`: Returns `Some(value)`
263+
if the field is set or `None` if it's unset.
261264
* `fn set_foo(&mut self, val: impl IntoProxied<ProtoString>)`: Sets the value
262265
of the field. `&str`, `String`, `&ProtoStr` and `ProtoString` all
263266
implelement `IntoProxied` and can be passed to this method.
@@ -305,8 +308,8 @@ The compiler generates the following accessor methods:
305308
* `fn has_foo(&self) -> bool`: Returns `true` if the field is set.
306309
* `fn foo(&self) -> Bar`: Returns the current value of the field. If the field
307310
is not set, it returns the default value.
308-
* `fn foo_opt(&self) -> Optional<Bar>`: Returns an optional with the variant
309-
`Set(value)` if the field is set or `Unset(default value)` if it's unset.
311+
* `fn foo_opt(&self) -> std::option::Option<Bar>`: Returns `Some(value)` if
312+
the field is set or `None` if it's unset.
310313
* `fn set_foo(&mut self, val: Bar)`: Sets the value of the field. After
311314
calling this, `has_foo()` will return `true` and `foo()` will return
312315
`value`.
@@ -338,9 +341,8 @@ The compiler will generate the following accessor methods:
338341
* `fn foo_mut(&mut self) -> BarMut<'_>`: Returns a mutable handle to the
339342
current value of the field. Sets the field if it is not set. After calling
340343
this method, `has_foo()` returns true.
341-
* `fn foo_opt(&self) -> protobuf::Optional<BarView>`: If the field is set,
342-
returns the variant `Set` with its `value`. Else returns the variant `Unset`
343-
with the default value.
344+
* `fn foo_opt(&self) -> std::option::Option<BarView<'_>>`: If the field is
345+
set, returns `Some` with its view. Else returns `None`.
344346
* `fn set_foo(&mut self, value: impl protobuf::IntoProxied<Bar>)`: Sets the
345347
field to `value`. After calling this method, `has_foo()` returns `true`.
346348
* `fn has_foo(&self) -> bool`: Returns `true` if the field is set.
@@ -558,7 +560,7 @@ The compiler will generate the following 3 accessor methods:
558560
[`MapView` rustdoc](https://docs.rs/protobuf/4.33.5-release/protobuf/struct.MapView.html).
559561
* `fn weight_mut(&mut self) -> protobuf::MapMut<'_, i32, i32>`: Returns a
560562
mutable handle to the underlying map. See
561-
[`MapMut` rustdoc](https://docs.rs/protobuf/4.33.5-release/protobuf/struct.MapView.html).
563+
[`MapMut` rustdoc](https://docs.rs/protobuf/4.33.5-release/protobuf/struct.MapMut.html).
562564
* `fn set_weight(&mut self, src: protobuf::IntoProxied<Map<i32, i32>>)`: Sets
563565
the underlying map to `src`. Accepts a `MapView`, `MapMut` or `Map`. See
564566
[`Map` rustdoc](https://docs.rs/protobuf/4.33.5-release/protobuf/struct.Map.html).

0 commit comments

Comments
 (0)