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}
255impl ::buffa::MessageName for FieldMask {
256    const PACKAGE: &'static str = "google.protobuf";
257    const NAME: &'static str = "FieldMask";
258    const FULL_NAME: &'static str = "google.protobuf.FieldMask";
259    const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.FieldMask";
260}
261impl ::buffa::Message for FieldMask {
262    /// Returns the total encoded size in bytes.
263    ///
264    /// The result is a `u32`; the protobuf specification requires all
265    /// messages to fit within 2 GiB (2,147,483,647 bytes), so a
266    /// compliant message will never overflow this type.
267    #[allow(clippy::let_and_return)]
268    fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 {
269        #[allow(unused_imports)]
270        use ::buffa::Enumeration as _;
271        let mut size = 0u32;
272        for v in &self.paths {
273            size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
274        }
275        size += self.__buffa_unknown_fields.encoded_len() as u32;
276        size
277    }
278    fn write_to(
279        &self,
280        _cache: &mut ::buffa::SizeCache,
281        buf: &mut impl ::buffa::bytes::BufMut,
282    ) {
283        #[allow(unused_imports)]
284        use ::buffa::Enumeration as _;
285        for v in &self.paths {
286            ::buffa::encoding::Tag::new(
287                    1u32,
288                    ::buffa::encoding::WireType::LengthDelimited,
289                )
290                .encode(buf);
291            ::buffa::types::encode_string(v, buf);
292        }
293        self.__buffa_unknown_fields.write_to(buf);
294    }
295    fn merge_field(
296        &mut self,
297        tag: ::buffa::encoding::Tag,
298        buf: &mut impl ::buffa::bytes::Buf,
299        depth: u32,
300    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
301        #[allow(unused_imports)]
302        use ::buffa::bytes::Buf as _;
303        #[allow(unused_imports)]
304        use ::buffa::Enumeration as _;
305        match tag.field_number() {
306            1u32 => {
307                if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
308                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
309                        field_number: 1u32,
310                        expected: 2u8,
311                        actual: tag.wire_type() as u8,
312                    });
313                }
314                self.paths.push(::buffa::types::decode_string(buf)?);
315            }
316            _ => {
317                self.__buffa_unknown_fields
318                    .push(::buffa::encoding::decode_unknown_field(tag, buf, depth)?);
319            }
320        }
321        ::core::result::Result::Ok(())
322    }
323    fn clear(&mut self) {
324        self.paths.clear();
325        self.__buffa_unknown_fields.clear();
326    }
327}
328impl ::buffa::ExtensionSet for FieldMask {
329    const PROTO_FQN: &'static str = "google.protobuf.FieldMask";
330    fn unknown_fields(&self) -> &::buffa::UnknownFields {
331        &self.__buffa_unknown_fields
332    }
333    fn unknown_fields_mut(&mut self) -> &mut ::buffa::UnknownFields {
334        &mut self.__buffa_unknown_fields
335    }
336}
337impl ::buffa::text::TextFormat for FieldMask {
338    fn encode_text(
339        &self,
340        enc: &mut ::buffa::text::TextEncoder<'_>,
341    ) -> ::core::fmt::Result {
342        #[allow(unused_imports)]
343        use ::buffa::Enumeration as _;
344        for __v in &self.paths {
345            enc.write_field_name("paths")?;
346            enc.write_string(__v)?;
347        }
348        enc.write_unknown_fields(&self.__buffa_unknown_fields)?;
349        ::core::result::Result::Ok(())
350    }
351    fn merge_text(
352        &mut self,
353        dec: &mut ::buffa::text::TextDecoder<'_>,
354    ) -> ::core::result::Result<(), ::buffa::text::ParseError> {
355        #[allow(unused_imports)]
356        use ::buffa::Enumeration as _;
357        while let ::core::option::Option::Some(__name) = dec.read_field_name()? {
358            match __name {
359                "paths" => {
360                    dec.read_repeated_into(
361                        &mut self.paths,
362                        |__d| ::core::result::Result::Ok(__d.read_string()?.into_owned()),
363                    )?
364                }
365                _ => dec.skip_value()?,
366            }
367        }
368        ::core::result::Result::Ok(())
369    }
370}
371#[doc(hidden)]
372pub const __FIELD_MASK_TEXT_ANY: ::buffa::type_registry::TextAnyEntry = ::buffa::type_registry::TextAnyEntry {
373    type_url: "type.googleapis.com/google.protobuf.FieldMask",
374    text_encode: ::buffa::type_registry::any_encode_text::<FieldMask>,
375    text_merge: ::buffa::type_registry::any_merge_text::<FieldMask>,
376};