Skip to main content

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}
249impl ::buffa::DefaultInstance for FieldMask {
250    fn default_instance() -> &'static Self {
251        static VALUE: ::buffa::__private::OnceBox<FieldMask> = ::buffa::__private::OnceBox::new();
252        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
253    }
254}
255#[cfg(feature = "reflect")]
256const _: () = {
257    impl ::buffa_descriptor::reflect::ReflectMessage for FieldMask {
258        fn message_descriptor(&self) -> &::buffa_descriptor::MessageDescriptor {
259            __buffa::reflect::descriptor_pool()
260                .message(Self::__buffa_reflect_message_index())
261        }
262        fn pool(
263            &self,
264        ) -> &::buffa::alloc::sync::Arc<::buffa_descriptor::DescriptorPool> {
265            __buffa::reflect::descriptor_pool()
266        }
267        fn unknown_fields(&self) -> &::buffa::UnknownFields {
268            &self.__buffa_unknown_fields
269        }
270        fn get(
271            &self,
272            field: &::buffa_descriptor::FieldDescriptor,
273        ) -> ::buffa_descriptor::reflect::ValueRef<'_> {
274            #[allow(unused_imports)]
275            use ::buffa::Enumeration as _;
276            match field.number() {
277                1u32 => ::buffa_descriptor::reflect::ValueRef::List(&self.paths),
278                _ => {
279                    ::core::debug_assert!(
280                        false,
281                        "field number {} is not a member of this message's reflect get()",
282                        field.number(),
283                    );
284                    ::buffa_descriptor::reflect::ValueRef::Bool(false)
285                }
286            }
287        }
288        fn has(&self, field: &::buffa_descriptor::FieldDescriptor) -> bool {
289            match field.number() {
290                1u32 => !self.paths.is_empty(),
291                _ => false,
292            }
293        }
294        fn for_each_set(
295            &self,
296            f: &mut dyn ::core::ops::FnMut(
297                &::buffa_descriptor::FieldDescriptor,
298                ::buffa_descriptor::reflect::ValueRef<'_>,
299            ),
300        ) {
301            let md = ::buffa_descriptor::reflect::ReflectMessage::message_descriptor(
302                self,
303            );
304            for fd in md.fields() {
305                if ::buffa_descriptor::reflect::ReflectMessage::has(self, fd) {
306                    f(fd, ::buffa_descriptor::reflect::ReflectMessage::get(self, fd));
307                }
308            }
309        }
310        fn to_dynamic(&self) -> ::buffa_descriptor::reflect::DynamicMessage {
311            ::buffa_descriptor::reflect::DynamicMessage::from_message(
312                self,
313                ::buffa::alloc::sync::Arc::clone(__buffa::reflect::descriptor_pool()),
314                Self::__buffa_reflect_message_index(),
315            )
316        }
317    }
318    impl ::buffa_descriptor::reflect::ReflectElement for FieldMask {
319        fn as_value_ref(&self) -> ::buffa_descriptor::reflect::ValueRef<'_> {
320            ::buffa_descriptor::reflect::ValueRef::Message(
321                ::buffa_descriptor::reflect::ReflectCow::Borrowed(self),
322            )
323        }
324    }
325    impl FieldMask {
326        /// Memoized `MessageIndex` for this message type, resolved once
327        /// against the package's embedded descriptor pool.
328        #[doc(hidden)]
329        fn __buffa_reflect_message_index() -> ::buffa_descriptor::MessageIndex {
330            static IDX: ::std::sync::OnceLock<::buffa_descriptor::MessageIndex> = ::std::sync::OnceLock::new();
331            *IDX
332                .get_or_init(|| {
333                    __buffa::reflect::descriptor_pool()
334                        .message_index(<Self as ::buffa::MessageName>::FULL_NAME)
335                        .expect(
336                            "generated message is registered in the embedded descriptor pool",
337                        )
338                })
339        }
340    }
341    impl ::buffa_descriptor::reflect::Reflectable for FieldMask {
342        /// Vtable-mode reflective handle: borrows `self` directly. No
343        /// encode/decode round-trip and no allocation — the reflective
344        /// accessors read this message's fields in place.
345        fn reflect(&self) -> ::buffa_descriptor::reflect::ReflectCow<'_> {
346            ::buffa_descriptor::reflect::ReflectCow::Borrowed(self)
347        }
348    }
349};
350impl ::buffa::MessageName for FieldMask {
351    const PACKAGE: &'static str = "google.protobuf";
352    const NAME: &'static str = "FieldMask";
353    const FULL_NAME: &'static str = "google.protobuf.FieldMask";
354    const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.FieldMask";
355}
356impl ::buffa::Message for FieldMask {
357    /// Returns the total encoded size in bytes.
358    ///
359    /// The result is a `u32`; the protobuf specification requires all
360    /// messages to fit within 2 GiB (2,147,483,647 bytes), so a
361    /// compliant message will never overflow this type.
362    #[allow(clippy::let_and_return)]
363    fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 {
364        #[allow(unused_imports)]
365        use ::buffa::Enumeration as _;
366        let mut size = 0u32;
367        for v in &self.paths {
368            size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
369        }
370        size += self.__buffa_unknown_fields.encoded_len() as u32;
371        size
372    }
373    fn write_to(
374        &self,
375        _cache: &mut ::buffa::SizeCache,
376        buf: &mut impl ::buffa::bytes::BufMut,
377    ) {
378        #[allow(unused_imports)]
379        use ::buffa::Enumeration as _;
380        for v in &self.paths {
381            ::buffa::encoding::Tag::new(
382                    1u32,
383                    ::buffa::encoding::WireType::LengthDelimited,
384                )
385                .encode(buf);
386            ::buffa::types::encode_string(v, buf);
387        }
388        self.__buffa_unknown_fields.write_to(buf);
389    }
390    fn merge_field(
391        &mut self,
392        tag: ::buffa::encoding::Tag,
393        buf: &mut impl ::buffa::bytes::Buf,
394        depth: u32,
395    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
396        #[allow(unused_imports)]
397        use ::buffa::bytes::Buf as _;
398        #[allow(unused_imports)]
399        use ::buffa::Enumeration as _;
400        match tag.field_number() {
401            1u32 => {
402                if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
403                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
404                        field_number: 1u32,
405                        expected: 2u8,
406                        actual: tag.wire_type() as u8,
407                    });
408                }
409                self.paths.push(::buffa::types::decode_string(buf)?);
410            }
411            _ => {
412                self.__buffa_unknown_fields
413                    .push(::buffa::encoding::decode_unknown_field(tag, buf, depth)?);
414            }
415        }
416        ::core::result::Result::Ok(())
417    }
418    fn clear(&mut self) {
419        self.paths.clear();
420        self.__buffa_unknown_fields.clear();
421    }
422}
423impl ::buffa::ExtensionSet for FieldMask {
424    const PROTO_FQN: &'static str = "google.protobuf.FieldMask";
425    fn unknown_fields(&self) -> &::buffa::UnknownFields {
426        &self.__buffa_unknown_fields
427    }
428    fn unknown_fields_mut(&mut self) -> &mut ::buffa::UnknownFields {
429        &mut self.__buffa_unknown_fields
430    }
431}
432impl ::buffa::text::TextFormat for FieldMask {
433    fn encode_text(
434        &self,
435        enc: &mut ::buffa::text::TextEncoder<'_>,
436    ) -> ::core::fmt::Result {
437        #[allow(unused_imports)]
438        use ::buffa::Enumeration as _;
439        for __v in &self.paths {
440            enc.write_field_name("paths")?;
441            enc.write_string(__v)?;
442        }
443        enc.write_unknown_fields(&self.__buffa_unknown_fields)?;
444        ::core::result::Result::Ok(())
445    }
446    fn merge_text(
447        &mut self,
448        dec: &mut ::buffa::text::TextDecoder<'_>,
449    ) -> ::core::result::Result<(), ::buffa::text::ParseError> {
450        #[allow(unused_imports)]
451        use ::buffa::Enumeration as _;
452        while let ::core::option::Option::Some(__name) = dec.read_field_name()? {
453            match __name {
454                "paths" => {
455                    dec.read_repeated_into(
456                        &mut self.paths,
457                        |__d| ::core::result::Result::Ok(__d.read_string()?.into_owned()),
458                    )?
459                }
460                _ => dec.skip_value()?,
461            }
462        }
463        ::core::result::Result::Ok(())
464    }
465}
466#[doc(hidden)]
467pub const __FIELD_MASK_TEXT_ANY: ::buffa::type_registry::TextAnyEntry = ::buffa::type_registry::TextAnyEntry {
468    type_url: "type.googleapis.com/google.protobuf.FieldMask",
469    text_encode: ::buffa::type_registry::any_encode_text::<FieldMask>,
470    text_merge: ::buffa::type_registry::any_merge_text::<FieldMask>,
471};