buffa_types/generated/google.protobuf.field_mask.rs
1// @generated by buffa-codegen. DO NOT EDIT.
2// source: google/protobuf/field_mask.proto
3
4/// `FieldMask` represents a set of symbolic field paths, for example:
5///
6/// ```text
7/// paths: "f.a"
8/// paths: "f.b.d"
9/// ```
10///
11/// Here `f` represents a field in some root message, `a` and `b`
12/// fields in the message found in `f`, and `d` a field found in the
13/// message in `f.b`.
14///
15/// Field masks are used to specify a subset of fields that should be
16/// returned by a get operation or modified by an update operation.
17/// Field masks also have a custom JSON encoding (see below).
18///
19/// # Field Masks in Projections
20///
21/// When used in the context of a projection, a response message or
22/// sub-message is filtered by the API to only contain those fields as
23/// specified in the mask. For example, if the mask in the previous
24/// example is applied to a response message as follows:
25///
26/// ```text
27/// f {
28/// a : 22
29/// b {
30/// d : 1
31/// x : 2
32/// }
33/// y : 13
34/// }
35/// z: 8
36/// ```
37///
38/// The result will not contain specific values for fields x,y and z
39/// (their value will be set to the default, and omitted in proto text
40/// output):
41///
42///
43/// ```text
44/// f {
45/// a : 22
46/// b {
47/// d : 1
48/// }
49/// }
50/// ```
51///
52/// A repeated field is not allowed except at the last position of a
53/// paths string.
54///
55/// If a FieldMask object is not present in a get operation, the
56/// operation applies to all fields (as if a FieldMask of all fields
57/// had been specified).
58///
59/// Note that a field mask does not necessarily apply to the
60/// top-level response message. In case of a REST get operation, the
61/// field mask applies directly to the response, but in case of a REST
62/// list operation, the mask instead applies to each individual message
63/// in the returned resource list. In case of a REST custom method,
64/// other definitions may be used. Where the mask applies will be
65/// clearly documented together with its declaration in the API. In
66/// any case, the effect on the returned resource/resources is required
67/// behavior for APIs.
68///
69/// # Field Masks in Update Operations
70///
71/// A field mask in update operations specifies which fields of the
72/// targeted resource are going to be updated. The API is required
73/// to only change the values of the fields as specified in the mask
74/// and leave the others untouched. If a resource is passed in to
75/// describe the updated values, the API ignores the values of all
76/// fields not covered by the mask.
77///
78/// If a repeated field is specified for an update operation, new values will
79/// be appended to the existing repeated field in the target resource. Note that
80/// a repeated field is only allowed in the last position of a `paths` string.
81///
82/// If a sub-message is specified in the last position of the field mask for an
83/// update operation, then new value will be merged into the existing sub-message
84/// in the target resource.
85///
86/// For example, given the target message:
87///
88/// ```text
89/// f {
90/// b {
91/// d: 1
92/// x: 2
93/// }
94/// c: [1]
95/// }
96/// ```
97///
98/// And an update message:
99///
100/// ```text
101/// f {
102/// b {
103/// d: 10
104/// }
105/// c: [2]
106/// }
107/// ```
108///
109/// then if the field mask is:
110///
111/// paths: \["f.b", "f.c"\]
112///
113/// then the result will be:
114///
115/// ```text
116/// f {
117/// b {
118/// d: 10
119/// x: 2
120/// }
121/// c: [1, 2]
122/// }
123/// ```
124///
125/// An implementation may provide options to override this default behavior for
126/// repeated and message fields.
127///
128/// In order to reset a field's value to the default, the field must
129/// be in the mask and set to the default value in the provided resource.
130/// Hence, in order to reset all fields of a resource, provide a default
131/// instance of the resource and set all fields in the mask, or do
132/// not provide a mask as described below.
133///
134/// If a field mask is not present on update, the operation applies to
135/// all fields (as if a field mask of all fields has been specified).
136/// Note that in the presence of schema evolution, this may mean that
137/// fields the client does not know and has therefore not filled into
138/// the request will be reset to their default. If this is unwanted
139/// behavior, a specific service may require a client to always specify
140/// a field mask, producing an error if not.
141///
142/// As with get operations, the location of the resource which
143/// describes the updated values in the request message depends on the
144/// operation kind. In any case, the effect of the field mask is
145/// required to be honored by the API.
146///
147/// ## Considerations for HTTP REST
148///
149/// The HTTP kind of an update operation which uses a field mask must
150/// be set to PATCH instead of PUT in order to satisfy HTTP semantics
151/// (PUT must only be used for full updates).
152///
153/// # JSON Encoding of Field Masks
154///
155/// In JSON, a field mask is encoded as a single string where paths are
156/// separated by a comma. Fields name in each path are converted
157/// to/from lower-camel naming conventions.
158///
159/// As an example, consider the following message declarations:
160///
161/// ```text
162/// message Profile {
163/// User user = 1;
164/// Photo photo = 2;
165/// }
166/// message User {
167/// string display_name = 1;
168/// string address = 2;
169/// }
170/// ```
171///
172/// In proto a field mask for `Profile` may look as such:
173///
174/// ```text
175/// mask {
176/// paths: "user.display_name"
177/// paths: "photo"
178/// }
179/// ```
180///
181/// In JSON, the same mask is represented as below:
182///
183/// ```text
184/// {
185/// mask: "user.displayName,photo"
186/// }
187/// ```
188///
189/// # Field Masks and Oneof Fields
190///
191/// Field masks treat fields in oneofs just as regular fields. Consider the
192/// following message:
193///
194/// ```text
195/// message SampleMessage {
196/// oneof test_oneof {
197/// string name = 4;
198/// SubMessage sub_message = 9;
199/// }
200/// }
201/// ```
202///
203/// The field mask can be:
204///
205/// ```text
206/// mask {
207/// paths: "name"
208/// }
209/// ```
210///
211/// Or:
212///
213/// ```text
214/// mask {
215/// paths: "sub_message"
216/// }
217/// ```
218///
219/// Note that oneof type names ("test_oneof" in this case) cannot be used in
220/// paths.
221///
222/// ## Field Mask Verification
223///
224/// The implementation of any API method which has a FieldMask type field in the
225/// request should verify the included field paths, and return an
226/// `INVALID_ARGUMENT` error if any path is unmappable.
227#[derive(Clone, PartialEq, Default)]
228#[cfg_attr(feature = "arbitrary", derive(::arbitrary::Arbitrary))]
229pub struct FieldMask {
230 /// The set of field mask paths.
231 ///
232 /// Field 1: `paths`
233 pub paths: ::buffa::alloc::vec::Vec<::buffa::alloc::string::String>,
234 #[doc(hidden)]
235 pub __buffa_unknown_fields: ::buffa::UnknownFields,
236}
237impl ::core::fmt::Debug for FieldMask {
238 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
239 f.debug_struct("FieldMask").field("paths", &self.paths).finish()
240 }
241}
242impl FieldMask {
243 /// Protobuf type URL for this message, for use with `Any::pack` and
244 /// `Any::unpack_if`.
245 ///
246 /// Format: `type.googleapis.com/<fully.qualified.TypeName>`
247 pub const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.FieldMask";
248}
249::buffa::impl_default_instance!(FieldMask);
250#[cfg(feature = "reflect")]
251const _: () = {
252 impl ::buffa_descriptor::reflect::ReflectMessage for FieldMask {
253 fn message_descriptor(&self) -> &::buffa_descriptor::MessageDescriptor {
254 __buffa::reflect::descriptor_pool()
255 .message(Self::__buffa_reflect_message_index())
256 }
257 fn pool(
258 &self,
259 ) -> &::buffa::alloc::sync::Arc<::buffa_descriptor::DescriptorPool> {
260 __buffa::reflect::descriptor_pool()
261 }
262 fn unknown_fields(&self) -> &::buffa::UnknownFields {
263 &self.__buffa_unknown_fields
264 }
265 fn get(
266 &self,
267 field: &::buffa_descriptor::FieldDescriptor,
268 ) -> ::buffa_descriptor::reflect::ValueRef<'_> {
269 #[allow(unused_imports)]
270 use ::buffa::Enumeration as _;
271 match field.number() {
272 1u32 => ::buffa_descriptor::reflect::ValueRef::List(&self.paths),
273 _ => {
274 ::core::debug_assert!(
275 false,
276 "field number {} is not a member of this message's reflect get()",
277 field.number(),
278 );
279 ::buffa_descriptor::reflect::ValueRef::Bool(false)
280 }
281 }
282 }
283 fn has(&self, field: &::buffa_descriptor::FieldDescriptor) -> bool {
284 match field.number() {
285 1u32 => !self.paths.is_empty(),
286 _ => false,
287 }
288 }
289 fn for_each_set(
290 &self,
291 f: &mut dyn ::core::ops::FnMut(
292 &::buffa_descriptor::FieldDescriptor,
293 ::buffa_descriptor::reflect::ValueRef<'_>,
294 ),
295 ) {
296 let md = ::buffa_descriptor::reflect::ReflectMessage::message_descriptor(
297 self,
298 );
299 for fd in md.fields() {
300 if ::buffa_descriptor::reflect::ReflectMessage::has(self, fd) {
301 f(fd, ::buffa_descriptor::reflect::ReflectMessage::get(self, fd));
302 }
303 }
304 }
305 fn to_dynamic(&self) -> ::buffa_descriptor::reflect::DynamicMessage {
306 ::buffa_descriptor::reflect::DynamicMessage::from_message(
307 self,
308 ::buffa::alloc::sync::Arc::clone(__buffa::reflect::descriptor_pool()),
309 Self::__buffa_reflect_message_index(),
310 )
311 }
312 }
313 impl ::buffa_descriptor::reflect::ReflectElement for FieldMask {
314 #[inline]
315 fn as_value_ref(&self) -> ::buffa_descriptor::reflect::ValueRef<'_> {
316 ::buffa_descriptor::reflect::ValueRef::Message(
317 ::buffa_descriptor::reflect::ReflectCow::Borrowed(self),
318 )
319 }
320 }
321 impl FieldMask {
322 /// Memoized `MessageIndex` for this message type, resolved once
323 /// against the package's embedded descriptor pool.
324 #[doc(hidden)]
325 fn __buffa_reflect_message_index() -> ::buffa_descriptor::MessageIndex {
326 static IDX: ::std::sync::OnceLock<::buffa_descriptor::MessageIndex> = ::std::sync::OnceLock::new();
327 *IDX
328 .get_or_init(|| {
329 __buffa::reflect::descriptor_pool()
330 .message_index(<Self as ::buffa::MessageName>::FULL_NAME)
331 .expect(
332 "generated message is registered in the embedded descriptor pool",
333 )
334 })
335 }
336 }
337 impl ::buffa_descriptor::reflect::Reflectable for FieldMask {
338 /// Vtable-mode reflective handle: borrows `self` directly. No
339 /// encode/decode round-trip and no allocation — the reflective
340 /// accessors read this message's fields in place.
341 #[inline]
342 fn reflect(&self) -> ::buffa_descriptor::reflect::ReflectCow<'_> {
343 ::buffa_descriptor::reflect::ReflectCow::Borrowed(self)
344 }
345 }
346};
347impl ::buffa::MessageName for FieldMask {
348 const PACKAGE: &'static str = "google.protobuf";
349 const NAME: &'static str = "FieldMask";
350 const FULL_NAME: &'static str = "google.protobuf.FieldMask";
351 const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.FieldMask";
352}
353impl ::buffa::Message for FieldMask {
354 /// Returns the total encoded size in bytes.
355 ///
356 /// Accumulates in `u64` (which cannot overflow for in-memory
357 /// data) and saturates to `u32` at return, so a message whose
358 /// encoded size exceeds the 2 GiB protobuf limit yields a value
359 /// above [`::buffa::MAX_MESSAGE_BYTES`] that the encode entry
360 /// points reject, never a silently wrapped size.
361 #[allow(clippy::let_and_return)]
362 fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 {
363 #[allow(unused_imports)]
364 use ::buffa::Enumeration as _;
365 let mut size = 0u64;
366 for v in &self.paths {
367 size += 1u64 + ::buffa::types::string_encoded_len(v) as u64;
368 }
369 size += self.__buffa_unknown_fields.encoded_len() as u64;
370 ::buffa::saturate_size(size)
371 }
372 fn write_to(
373 &self,
374 _cache: &mut ::buffa::SizeCache,
375 buf: &mut impl ::buffa::EncodeSink,
376 ) {
377 #[allow(unused_imports)]
378 use ::buffa::Enumeration as _;
379 for v in &self.paths {
380 ::buffa::types::put_string_field(1u32, v, buf);
381 }
382 self.__buffa_unknown_fields.write_to(buf);
383 }
384 fn merge_field(
385 &mut self,
386 tag: ::buffa::encoding::Tag,
387 buf: &mut impl ::buffa::bytes::Buf,
388 ctx: ::buffa::DecodeContext<'_>,
389 ) -> ::core::result::Result<(), ::buffa::DecodeError> {
390 #[allow(unused_imports)]
391 use ::buffa::bytes::Buf as _;
392 #[allow(unused_imports)]
393 use ::buffa::Enumeration as _;
394 match tag.field_number() {
395 1u32 => {
396 ::buffa::encoding::check_wire_type(
397 tag,
398 ::buffa::encoding::WireType::LengthDelimited,
399 )?;
400 let __elem = ::buffa::types::decode_string(buf)?;
401 ctx.register_element_memory(
402 ::buffa::__private::element_footprint(&__elem),
403 )?;
404 self.paths.push(__elem);
405 }
406 _ => {
407 self.__buffa_unknown_fields
408 .push(::buffa::encoding::decode_unknown_field(tag, buf, ctx)?);
409 }
410 }
411 ::core::result::Result::Ok(())
412 }
413 fn clear(&mut self) {
414 self.paths.clear();
415 self.__buffa_unknown_fields.clear();
416 }
417}
418impl ::buffa::ExtensionSet for FieldMask {
419 const PROTO_FQN: &'static str = "google.protobuf.FieldMask";
420 fn unknown_fields(&self) -> &::buffa::UnknownFields {
421 &self.__buffa_unknown_fields
422 }
423 fn unknown_fields_mut(&mut self) -> &mut ::buffa::UnknownFields {
424 &mut self.__buffa_unknown_fields
425 }
426}
427impl ::buffa::text::TextFormat for FieldMask {
428 fn encode_text(
429 &self,
430 enc: &mut ::buffa::text::TextEncoder<'_>,
431 ) -> ::core::fmt::Result {
432 #[allow(unused_imports)]
433 use ::buffa::Enumeration as _;
434 for __v in &self.paths {
435 enc.write_field_name("paths")?;
436 enc.write_string(__v)?;
437 }
438 enc.write_unknown_fields(&self.__buffa_unknown_fields)?;
439 ::core::result::Result::Ok(())
440 }
441 fn merge_text(
442 &mut self,
443 dec: &mut ::buffa::text::TextDecoder<'_>,
444 ) -> ::core::result::Result<(), ::buffa::text::ParseError> {
445 #[allow(unused_imports)]
446 use ::buffa::Enumeration as _;
447 while let ::core::option::Option::Some(__name) = dec.read_field_name()? {
448 match __name {
449 "paths" => {
450 dec.read_repeated_into(
451 &mut self.paths,
452 |__d| ::core::result::Result::Ok(__d.read_string()?.into_owned()),
453 )?
454 }
455 _ => dec.skip_value()?,
456 }
457 }
458 ::core::result::Result::Ok(())
459 }
460}
461#[doc(hidden)]
462pub const __FIELD_MASK_TEXT_ANY: ::buffa::type_registry::TextAnyEntry = ::buffa::type_registry::TextAnyEntry {
463 type_url: "type.googleapis.com/google.protobuf.FieldMask",
464 text_encode: ::buffa::type_registry::any_encode_text::<FieldMask>,
465 text_merge: ::buffa::type_registry::any_merge_text::<FieldMask>,
466};