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 #[inline]
320 fn as_value_ref(&self) -> ::buffa_descriptor::reflect::ValueRef<'_> {
321 ::buffa_descriptor::reflect::ValueRef::Message(
322 ::buffa_descriptor::reflect::ReflectCow::Borrowed(self),
323 )
324 }
325 }
326 impl FieldMask {
327 /// Memoized `MessageIndex` for this message type, resolved once
328 /// against the package's embedded descriptor pool.
329 #[doc(hidden)]
330 fn __buffa_reflect_message_index() -> ::buffa_descriptor::MessageIndex {
331 static IDX: ::std::sync::OnceLock<::buffa_descriptor::MessageIndex> = ::std::sync::OnceLock::new();
332 *IDX
333 .get_or_init(|| {
334 __buffa::reflect::descriptor_pool()
335 .message_index(<Self as ::buffa::MessageName>::FULL_NAME)
336 .expect(
337 "generated message is registered in the embedded descriptor pool",
338 )
339 })
340 }
341 }
342 impl ::buffa_descriptor::reflect::Reflectable for FieldMask {
343 /// Vtable-mode reflective handle: borrows `self` directly. No
344 /// encode/decode round-trip and no allocation — the reflective
345 /// accessors read this message's fields in place.
346 #[inline]
347 fn reflect(&self) -> ::buffa_descriptor::reflect::ReflectCow<'_> {
348 ::buffa_descriptor::reflect::ReflectCow::Borrowed(self)
349 }
350 }
351};
352impl ::buffa::MessageName for FieldMask {
353 const PACKAGE: &'static str = "google.protobuf";
354 const NAME: &'static str = "FieldMask";
355 const FULL_NAME: &'static str = "google.protobuf.FieldMask";
356 const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.FieldMask";
357}
358impl ::buffa::Message for FieldMask {
359 /// Returns the total encoded size in bytes.
360 ///
361 /// The result is a `u32`; the protobuf specification requires all
362 /// messages to fit within 2 GiB (2,147,483,647 bytes), so a
363 /// compliant message will never overflow this type.
364 #[allow(clippy::let_and_return)]
365 fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 {
366 #[allow(unused_imports)]
367 use ::buffa::Enumeration as _;
368 let mut size = 0u32;
369 for v in &self.paths {
370 size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
371 }
372 size += self.__buffa_unknown_fields.encoded_len() as u32;
373 size
374 }
375 fn write_to(
376 &self,
377 _cache: &mut ::buffa::SizeCache,
378 buf: &mut impl ::buffa::bytes::BufMut,
379 ) {
380 #[allow(unused_imports)]
381 use ::buffa::Enumeration as _;
382 for v in &self.paths {
383 ::buffa::encoding::Tag::new(
384 1u32,
385 ::buffa::encoding::WireType::LengthDelimited,
386 )
387 .encode(buf);
388 ::buffa::types::encode_string(v, buf);
389 }
390 self.__buffa_unknown_fields.write_to(buf);
391 }
392 fn merge_field(
393 &mut self,
394 tag: ::buffa::encoding::Tag,
395 buf: &mut impl ::buffa::bytes::Buf,
396 depth: u32,
397 ) -> ::core::result::Result<(), ::buffa::DecodeError> {
398 #[allow(unused_imports)]
399 use ::buffa::bytes::Buf as _;
400 #[allow(unused_imports)]
401 use ::buffa::Enumeration as _;
402 match tag.field_number() {
403 1u32 => {
404 if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
405 return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
406 field_number: 1u32,
407 expected: 2u8,
408 actual: tag.wire_type() as u8,
409 });
410 }
411 self.paths.push(::buffa::types::decode_string(buf)?);
412 }
413 _ => {
414 self.__buffa_unknown_fields
415 .push(::buffa::encoding::decode_unknown_field(tag, buf, depth)?);
416 }
417 }
418 ::core::result::Result::Ok(())
419 }
420 fn clear(&mut self) {
421 self.paths.clear();
422 self.__buffa_unknown_fields.clear();
423 }
424}
425impl ::buffa::ExtensionSet for FieldMask {
426 const PROTO_FQN: &'static str = "google.protobuf.FieldMask";
427 fn unknown_fields(&self) -> &::buffa::UnknownFields {
428 &self.__buffa_unknown_fields
429 }
430 fn unknown_fields_mut(&mut self) -> &mut ::buffa::UnknownFields {
431 &mut self.__buffa_unknown_fields
432 }
433}
434impl ::buffa::text::TextFormat for FieldMask {
435 fn encode_text(
436 &self,
437 enc: &mut ::buffa::text::TextEncoder<'_>,
438 ) -> ::core::fmt::Result {
439 #[allow(unused_imports)]
440 use ::buffa::Enumeration as _;
441 for __v in &self.paths {
442 enc.write_field_name("paths")?;
443 enc.write_string(__v)?;
444 }
445 enc.write_unknown_fields(&self.__buffa_unknown_fields)?;
446 ::core::result::Result::Ok(())
447 }
448 fn merge_text(
449 &mut self,
450 dec: &mut ::buffa::text::TextDecoder<'_>,
451 ) -> ::core::result::Result<(), ::buffa::text::ParseError> {
452 #[allow(unused_imports)]
453 use ::buffa::Enumeration as _;
454 while let ::core::option::Option::Some(__name) = dec.read_field_name()? {
455 match __name {
456 "paths" => {
457 dec.read_repeated_into(
458 &mut self.paths,
459 |__d| ::core::result::Result::Ok(__d.read_string()?.into_owned()),
460 )?
461 }
462 _ => dec.skip_value()?,
463 }
464 }
465 ::core::result::Result::Ok(())
466 }
467}
468#[doc(hidden)]
469pub const __FIELD_MASK_TEXT_ANY: ::buffa::type_registry::TextAnyEntry = ::buffa::type_registry::TextAnyEntry {
470 type_url: "type.googleapis.com/google.protobuf.FieldMask",
471 text_encode: ::buffa::type_registry::any_encode_text::<FieldMask>,
472 text_merge: ::buffa::type_registry::any_merge_text::<FieldMask>,
473};