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