buffa_types/generated/google.protobuf.field_mask.rs
1// @generated by protoc-gen-buffa. 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 #[doc(hidden)]
237 pub __buffa_cached_size: ::buffa::__private::CachedSize,
238}
239impl ::core::fmt::Debug for FieldMask {
240 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
241 f.debug_struct("FieldMask").field("paths", &self.paths).finish()
242 }
243}
244impl FieldMask {
245 /// Protobuf type URL for this message, for use with `Any::pack` and
246 /// `Any::unpack_if`.
247 ///
248 /// Format: `type.googleapis.com/<fully.qualified.TypeName>`
249 pub const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.FieldMask";
250}
251unsafe impl ::buffa::DefaultInstance for FieldMask {
252 fn default_instance() -> &'static Self {
253 static VALUE: ::buffa::__private::OnceBox<FieldMask> = ::buffa::__private::OnceBox::new();
254 VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
255 }
256}
257impl ::buffa::Message for FieldMask {
258 /// Returns the total encoded size in bytes.
259 ///
260 /// The result is a `u32`; the protobuf specification requires all
261 /// messages to fit within 2 GiB (2,147,483,647 bytes), so a
262 /// compliant message will never overflow this type.
263 fn compute_size(&self) -> u32 {
264 #[allow(unused_imports)]
265 use ::buffa::Enumeration as _;
266 let mut size = 0u32;
267 for v in &self.paths {
268 size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
269 }
270 size += self.__buffa_unknown_fields.encoded_len() as u32;
271 self.__buffa_cached_size.set(size);
272 size
273 }
274 fn write_to(&self, buf: &mut impl ::buffa::bytes::BufMut) {
275 #[allow(unused_imports)]
276 use ::buffa::Enumeration as _;
277 for v in &self.paths {
278 ::buffa::encoding::Tag::new(
279 1u32,
280 ::buffa::encoding::WireType::LengthDelimited,
281 )
282 .encode(buf);
283 ::buffa::types::encode_string(v, buf);
284 }
285 self.__buffa_unknown_fields.write_to(buf);
286 }
287 fn merge_field(
288 &mut self,
289 tag: ::buffa::encoding::Tag,
290 buf: &mut impl ::buffa::bytes::Buf,
291 depth: u32,
292 ) -> ::core::result::Result<(), ::buffa::DecodeError> {
293 #[allow(unused_imports)]
294 use ::buffa::bytes::Buf as _;
295 #[allow(unused_imports)]
296 use ::buffa::Enumeration as _;
297 match tag.field_number() {
298 1u32 => {
299 if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
300 return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
301 field_number: 1u32,
302 expected: 2u8,
303 actual: tag.wire_type() as u8,
304 });
305 }
306 self.paths.push(::buffa::types::decode_string(buf)?);
307 }
308 _ => {
309 self.__buffa_unknown_fields
310 .push(::buffa::encoding::decode_unknown_field(tag, buf, depth)?);
311 }
312 }
313 ::core::result::Result::Ok(())
314 }
315 fn cached_size(&self) -> u32 {
316 self.__buffa_cached_size.get()
317 }
318 fn clear(&mut self) {
319 self.paths.clear();
320 self.__buffa_unknown_fields.clear();
321 self.__buffa_cached_size.set(0);
322 }
323}
324impl ::buffa::ExtensionSet for FieldMask {
325 const PROTO_FQN: &'static str = "google.protobuf.FieldMask";
326 fn unknown_fields(&self) -> &::buffa::UnknownFields {
327 &self.__buffa_unknown_fields
328 }
329 fn unknown_fields_mut(&mut self) -> &mut ::buffa::UnknownFields {
330 &mut self.__buffa_unknown_fields
331 }
332}
333impl ::buffa::text::TextFormat for FieldMask {
334 fn encode_text(
335 &self,
336 enc: &mut ::buffa::text::TextEncoder<'_>,
337 ) -> ::core::fmt::Result {
338 #[allow(unused_imports)]
339 use ::buffa::Enumeration as _;
340 for __v in &self.paths {
341 enc.write_field_name("paths")?;
342 enc.write_string(__v)?;
343 }
344 enc.write_unknown_fields(&self.__buffa_unknown_fields)?;
345 ::core::result::Result::Ok(())
346 }
347 fn merge_text(
348 &mut self,
349 dec: &mut ::buffa::text::TextDecoder<'_>,
350 ) -> ::core::result::Result<(), ::buffa::text::ParseError> {
351 #[allow(unused_imports)]
352 use ::buffa::Enumeration as _;
353 while let ::core::option::Option::Some(__name) = dec.read_field_name()? {
354 match __name {
355 "paths" => {
356 dec.read_repeated_into(
357 &mut self.paths,
358 |__d| ::core::result::Result::Ok(__d.read_string()?.into_owned()),
359 )?
360 }
361 _ => dec.skip_value()?,
362 }
363 }
364 ::core::result::Result::Ok(())
365 }
366}
367#[doc(hidden)]
368pub const __FIELD_MASK_TEXT_ANY: ::buffa::type_registry::TextAnyEntry = ::buffa::type_registry::TextAnyEntry {
369 type_url: "type.googleapis.com/google.protobuf.FieldMask",
370 text_encode: ::buffa::type_registry::any_encode_text::<FieldMask>,
371 text_merge: ::buffa::type_registry::any_merge_text::<FieldMask>,
372};
373/// `FieldMask` represents a set of symbolic field paths, for example:
374///
375/// ```text
376/// paths: "f.a"
377/// paths: "f.b.d"
378/// ```
379///
380/// Here `f` represents a field in some root message, `a` and `b`
381/// fields in the message found in `f`, and `d` a field found in the
382/// message in `f.b`.
383///
384/// Field masks are used to specify a subset of fields that should be
385/// returned by a get operation or modified by an update operation.
386/// Field masks also have a custom JSON encoding (see below).
387///
388/// # Field Masks in Projections
389///
390/// When used in the context of a projection, a response message or
391/// sub-message is filtered by the API to only contain those fields as
392/// specified in the mask. For example, if the mask in the previous
393/// example is applied to a response message as follows:
394///
395/// ```text
396/// f {
397/// a : 22
398/// b {
399/// d : 1
400/// x : 2
401/// }
402/// y : 13
403/// }
404/// z: 8
405/// ```
406///
407/// The result will not contain specific values for fields x,y and z
408/// (their value will be set to the default, and omitted in proto text
409/// output):
410///
411///
412/// ```text
413/// f {
414/// a : 22
415/// b {
416/// d : 1
417/// }
418/// }
419/// ```
420///
421/// A repeated field is not allowed except at the last position of a
422/// paths string.
423///
424/// If a FieldMask object is not present in a get operation, the
425/// operation applies to all fields (as if a FieldMask of all fields
426/// had been specified).
427///
428/// Note that a field mask does not necessarily apply to the
429/// top-level response message. In case of a REST get operation, the
430/// field mask applies directly to the response, but in case of a REST
431/// list operation, the mask instead applies to each individual message
432/// in the returned resource list. In case of a REST custom method,
433/// other definitions may be used. Where the mask applies will be
434/// clearly documented together with its declaration in the API. In
435/// any case, the effect on the returned resource/resources is required
436/// behavior for APIs.
437///
438/// # Field Masks in Update Operations
439///
440/// A field mask in update operations specifies which fields of the
441/// targeted resource are going to be updated. The API is required
442/// to only change the values of the fields as specified in the mask
443/// and leave the others untouched. If a resource is passed in to
444/// describe the updated values, the API ignores the values of all
445/// fields not covered by the mask.
446///
447/// If a repeated field is specified for an update operation, new values will
448/// be appended to the existing repeated field in the target resource. Note that
449/// a repeated field is only allowed in the last position of a `paths` string.
450///
451/// If a sub-message is specified in the last position of the field mask for an
452/// update operation, then new value will be merged into the existing sub-message
453/// in the target resource.
454///
455/// For example, given the target message:
456///
457/// ```text
458/// f {
459/// b {
460/// d: 1
461/// x: 2
462/// }
463/// c: [1]
464/// }
465/// ```
466///
467/// And an update message:
468///
469/// ```text
470/// f {
471/// b {
472/// d: 10
473/// }
474/// c: [2]
475/// }
476/// ```
477///
478/// then if the field mask is:
479///
480/// paths: \["f.b", "f.c"\]
481///
482/// then the result will be:
483///
484/// ```text
485/// f {
486/// b {
487/// d: 10
488/// x: 2
489/// }
490/// c: [1, 2]
491/// }
492/// ```
493///
494/// An implementation may provide options to override this default behavior for
495/// repeated and message fields.
496///
497/// In order to reset a field's value to the default, the field must
498/// be in the mask and set to the default value in the provided resource.
499/// Hence, in order to reset all fields of a resource, provide a default
500/// instance of the resource and set all fields in the mask, or do
501/// not provide a mask as described below.
502///
503/// If a field mask is not present on update, the operation applies to
504/// all fields (as if a field mask of all fields has been specified).
505/// Note that in the presence of schema evolution, this may mean that
506/// fields the client does not know and has therefore not filled into
507/// the request will be reset to their default. If this is unwanted
508/// behavior, a specific service may require a client to always specify
509/// a field mask, producing an error if not.
510///
511/// As with get operations, the location of the resource which
512/// describes the updated values in the request message depends on the
513/// operation kind. In any case, the effect of the field mask is
514/// required to be honored by the API.
515///
516/// ## Considerations for HTTP REST
517///
518/// The HTTP kind of an update operation which uses a field mask must
519/// be set to PATCH instead of PUT in order to satisfy HTTP semantics
520/// (PUT must only be used for full updates).
521///
522/// # JSON Encoding of Field Masks
523///
524/// In JSON, a field mask is encoded as a single string where paths are
525/// separated by a comma. Fields name in each path are converted
526/// to/from lower-camel naming conventions.
527///
528/// As an example, consider the following message declarations:
529///
530/// ```text
531/// message Profile {
532/// User user = 1;
533/// Photo photo = 2;
534/// }
535/// message User {
536/// string display_name = 1;
537/// string address = 2;
538/// }
539/// ```
540///
541/// In proto a field mask for `Profile` may look as such:
542///
543/// ```text
544/// mask {
545/// paths: "user.display_name"
546/// paths: "photo"
547/// }
548/// ```
549///
550/// In JSON, the same mask is represented as below:
551///
552/// ```text
553/// {
554/// mask: "user.displayName,photo"
555/// }
556/// ```
557///
558/// # Field Masks and Oneof Fields
559///
560/// Field masks treat fields in oneofs just as regular fields. Consider the
561/// following message:
562///
563/// ```text
564/// message SampleMessage {
565/// oneof test_oneof {
566/// string name = 4;
567/// SubMessage sub_message = 9;
568/// }
569/// }
570/// ```
571///
572/// The field mask can be:
573///
574/// ```text
575/// mask {
576/// paths: "name"
577/// }
578/// ```
579///
580/// Or:
581///
582/// ```text
583/// mask {
584/// paths: "sub_message"
585/// }
586/// ```
587///
588/// Note that oneof type names ("test_oneof" in this case) cannot be used in
589/// paths.
590///
591/// ## Field Mask Verification
592///
593/// The implementation of any API method which has a FieldMask type field in the
594/// request should verify the included field paths, and return an
595/// `INVALID_ARGUMENT` error if any path is unmappable.
596#[derive(Clone, Debug, Default)]
597pub struct FieldMaskView<'a> {
598 /// The set of field mask paths.
599 ///
600 /// Field 1: `paths`
601 pub paths: ::buffa::RepeatedView<'a, &'a str>,
602 pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
603}
604impl<'a> FieldMaskView<'a> {
605 /// Decode from `buf`, enforcing a recursion depth limit for nested messages.
606 ///
607 /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`]
608 /// and by generated sub-message decode arms with `depth - 1`.
609 ///
610 /// **Not part of the public API.** Named with a leading underscore to
611 /// signal that it is for generated-code use only.
612 #[doc(hidden)]
613 pub fn _decode_depth(
614 buf: &'a [u8],
615 depth: u32,
616 ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
617 let mut view = Self::default();
618 view._merge_into_view(buf, depth)?;
619 ::core::result::Result::Ok(view)
620 }
621 /// Merge fields from `buf` into this view (proto merge semantics).
622 ///
623 /// Repeated fields append; singular fields last-wins; singular
624 /// MESSAGE fields merge recursively. Used by sub-message decode
625 /// arms when the same field appears multiple times on the wire.
626 ///
627 /// **Not part of the public API.**
628 #[doc(hidden)]
629 pub fn _merge_into_view(
630 &mut self,
631 buf: &'a [u8],
632 depth: u32,
633 ) -> ::core::result::Result<(), ::buffa::DecodeError> {
634 let _ = depth;
635 #[allow(unused_variables)]
636 let view = self;
637 let mut cur: &'a [u8] = buf;
638 while !cur.is_empty() {
639 let before_tag = cur;
640 let tag = ::buffa::encoding::Tag::decode(&mut cur)?;
641 match tag.field_number() {
642 1u32 => {
643 if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
644 return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
645 field_number: 1u32,
646 expected: 2u8,
647 actual: tag.wire_type() as u8,
648 });
649 }
650 view.paths.push(::buffa::types::borrow_str(&mut cur)?);
651 }
652 _ => {
653 ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?;
654 let span_len = before_tag.len() - cur.len();
655 view.__buffa_unknown_fields.push_raw(&before_tag[..span_len]);
656 }
657 }
658 }
659 ::core::result::Result::Ok(())
660 }
661}
662impl<'a> ::buffa::MessageView<'a> for FieldMaskView<'a> {
663 type Owned = FieldMask;
664 fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
665 Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT)
666 }
667 fn decode_view_with_limit(
668 buf: &'a [u8],
669 depth: u32,
670 ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
671 Self::_decode_depth(buf, depth)
672 }
673 /// Convert this view to the owned message type.
674 #[allow(clippy::redundant_closure, clippy::useless_conversion)]
675 fn to_owned_message(&self) -> FieldMask {
676 #[allow(unused_imports)]
677 use ::buffa::alloc::string::ToString as _;
678 FieldMask {
679 paths: self.paths.iter().map(|s| s.to_string()).collect(),
680 __buffa_unknown_fields: self
681 .__buffa_unknown_fields
682 .to_owned()
683 .unwrap_or_default()
684 .into(),
685 ..::core::default::Default::default()
686 }
687 }
688}
689unsafe impl ::buffa::DefaultViewInstance for FieldMaskView<'static> {
690 fn default_view_instance() -> &'static Self {
691 static VALUE: ::buffa::__private::OnceBox<FieldMaskView<'static>> = ::buffa::__private::OnceBox::new();
692 VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
693 }
694}
695unsafe impl<'a> ::buffa::HasDefaultViewInstance for FieldMaskView<'a> {
696 type Static = FieldMaskView<'static>;
697}