// @generated by buffa-codegen. DO NOT EDIT.
// source: google/protobuf/field_mask.proto

/// `FieldMask` represents a set of symbolic field paths, for example:
///
/// ```text
/// paths: "f.a"
/// paths: "f.b.d"
/// ```
///
/// Here `f` represents a field in some root message, `a` and `b`
/// fields in the message found in `f`, and `d` a field found in the
/// message in `f.b`.
///
/// Field masks are used to specify a subset of fields that should be
/// returned by a get operation or modified by an update operation.
/// Field masks also have a custom JSON encoding (see below).
///
/// # Field Masks in Projections
///
/// When used in the context of a projection, a response message or
/// sub-message is filtered by the API to only contain those fields as
/// specified in the mask. For example, if the mask in the previous
/// example is applied to a response message as follows:
///
/// ```text
/// f {
///   a : 22
///   b {
///     d : 1
///     x : 2
///   }
///   y : 13
/// }
/// z: 8
/// ```
///
/// The result will not contain specific values for fields x,y and z
/// (their value will be set to the default, and omitted in proto text
/// output):
///
///
/// ```text
/// f {
///   a : 22
///   b {
///     d : 1
///   }
/// }
/// ```
///
/// A repeated field is not allowed except at the last position of a
/// paths string.
///
/// If a FieldMask object is not present in a get operation, the
/// operation applies to all fields (as if a FieldMask of all fields
/// had been specified).
///
/// Note that a field mask does not necessarily apply to the
/// top-level response message. In case of a REST get operation, the
/// field mask applies directly to the response, but in case of a REST
/// list operation, the mask instead applies to each individual message
/// in the returned resource list. In case of a REST custom method,
/// other definitions may be used. Where the mask applies will be
/// clearly documented together with its declaration in the API.  In
/// any case, the effect on the returned resource/resources is required
/// behavior for APIs.
///
/// # Field Masks in Update Operations
///
/// A field mask in update operations specifies which fields of the
/// targeted resource are going to be updated. The API is required
/// to only change the values of the fields as specified in the mask
/// and leave the others untouched. If a resource is passed in to
/// describe the updated values, the API ignores the values of all
/// fields not covered by the mask.
///
/// If a repeated field is specified for an update operation, new values will
/// be appended to the existing repeated field in the target resource. Note that
/// a repeated field is only allowed in the last position of a `paths` string.
///
/// If a sub-message is specified in the last position of the field mask for an
/// update operation, then new value will be merged into the existing sub-message
/// in the target resource.
///
/// For example, given the target message:
///
/// ```text
/// f {
///   b {
///     d: 1
///     x: 2
///   }
///   c: [1]
/// }
/// ```
///
/// And an update message:
///
/// ```text
/// f {
///   b {
///     d: 10
///   }
///   c: [2]
/// }
/// ```
///
/// then if the field mask is:
///
///  paths: \["f.b", "f.c"\]
///
/// then the result will be:
///
/// ```text
/// f {
///   b {
///     d: 10
///     x: 2
///   }
///   c: [1, 2]
/// }
/// ```
///
/// An implementation may provide options to override this default behavior for
/// repeated and message fields.
///
/// In order to reset a field's value to the default, the field must
/// be in the mask and set to the default value in the provided resource.
/// Hence, in order to reset all fields of a resource, provide a default
/// instance of the resource and set all fields in the mask, or do
/// not provide a mask as described below.
///
/// If a field mask is not present on update, the operation applies to
/// all fields (as if a field mask of all fields has been specified).
/// Note that in the presence of schema evolution, this may mean that
/// fields the client does not know and has therefore not filled into
/// the request will be reset to their default. If this is unwanted
/// behavior, a specific service may require a client to always specify
/// a field mask, producing an error if not.
///
/// As with get operations, the location of the resource which
/// describes the updated values in the request message depends on the
/// operation kind. In any case, the effect of the field mask is
/// required to be honored by the API.
///
/// ## Considerations for HTTP REST
///
/// The HTTP kind of an update operation which uses a field mask must
/// be set to PATCH instead of PUT in order to satisfy HTTP semantics
/// (PUT must only be used for full updates).
///
/// # JSON Encoding of Field Masks
///
/// In JSON, a field mask is encoded as a single string where paths are
/// separated by a comma. Fields name in each path are converted
/// to/from lower-camel naming conventions.
///
/// As an example, consider the following message declarations:
///
/// ```text
/// message Profile {
///   User user = 1;
///   Photo photo = 2;
/// }
/// message User {
///   string display_name = 1;
///   string address = 2;
/// }
/// ```
///
/// In proto a field mask for `Profile` may look as such:
///
/// ```text
/// mask {
///   paths: "user.display_name"
///   paths: "photo"
/// }
/// ```
///
/// In JSON, the same mask is represented as below:
///
/// ```text
/// {
///   mask: "user.displayName,photo"
/// }
/// ```
///
/// # Field Masks and Oneof Fields
///
/// Field masks treat fields in oneofs just as regular fields. Consider the
/// following message:
///
/// ```text
/// message SampleMessage {
///   oneof test_oneof {
///     string name = 4;
///     SubMessage sub_message = 9;
///   }
/// }
/// ```
///
/// The field mask can be:
///
/// ```text
/// mask {
///   paths: "name"
/// }
/// ```
///
/// Or:
///
/// ```text
/// mask {
///   paths: "sub_message"
/// }
/// ```
///
/// Note that oneof type names ("test_oneof" in this case) cannot be used in
/// paths.
///
/// ## Field Mask Verification
///
/// The implementation of any API method which has a FieldMask type field in the
/// request should verify the included field paths, and return an
/// `INVALID_ARGUMENT` error if any path is unmappable.
#[derive(Clone, PartialEq, Default)]
#[cfg_attr(feature = "arbitrary", derive(::arbitrary::Arbitrary))]
pub struct FieldMask {
    /// The set of field mask paths.
    ///
    /// Field 1: `paths`
    pub paths: ::buffa::alloc::vec::Vec<::buffa::alloc::string::String>,
    #[doc(hidden)]
    pub __buffa_unknown_fields: ::buffa::UnknownFields,
}
impl ::core::fmt::Debug for FieldMask {
    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
        f.debug_struct("FieldMask").field("paths", &self.paths).finish()
    }
}
impl FieldMask {
    /// Protobuf type URL for this message, for use with `Any::pack` and
    /// `Any::unpack_if`.
    ///
    /// Format: `type.googleapis.com/<fully.qualified.TypeName>`
    pub const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.FieldMask";
}
impl ::buffa::DefaultInstance for FieldMask {
    fn default_instance() -> &'static Self {
        static VALUE: ::buffa::__private::OnceBox<FieldMask> = ::buffa::__private::OnceBox::new();
        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
    }
}
#[cfg(feature = "reflect")]
const _: () = {
    impl ::buffa_descriptor::reflect::ReflectMessage for FieldMask {
        fn message_descriptor(&self) -> &::buffa_descriptor::MessageDescriptor {
            __buffa::reflect::descriptor_pool()
                .message(Self::__buffa_reflect_message_index())
        }
        fn pool(
            &self,
        ) -> &::buffa::alloc::sync::Arc<::buffa_descriptor::DescriptorPool> {
            __buffa::reflect::descriptor_pool()
        }
        fn unknown_fields(&self) -> &::buffa::UnknownFields {
            &self.__buffa_unknown_fields
        }
        fn get(
            &self,
            field: &::buffa_descriptor::FieldDescriptor,
        ) -> ::buffa_descriptor::reflect::ValueRef<'_> {
            #[allow(unused_imports)]
            use ::buffa::Enumeration as _;
            match field.number() {
                1u32 => ::buffa_descriptor::reflect::ValueRef::List(&self.paths),
                _ => {
                    ::core::debug_assert!(
                        false,
                        "field number {} is not a member of this message's reflect get()",
                        field.number(),
                    );
                    ::buffa_descriptor::reflect::ValueRef::Bool(false)
                }
            }
        }
        fn has(&self, field: &::buffa_descriptor::FieldDescriptor) -> bool {
            match field.number() {
                1u32 => !self.paths.is_empty(),
                _ => false,
            }
        }
        fn for_each_set(
            &self,
            f: &mut dyn ::core::ops::FnMut(
                &::buffa_descriptor::FieldDescriptor,
                ::buffa_descriptor::reflect::ValueRef<'_>,
            ),
        ) {
            let md = ::buffa_descriptor::reflect::ReflectMessage::message_descriptor(
                self,
            );
            for fd in md.fields() {
                if ::buffa_descriptor::reflect::ReflectMessage::has(self, fd) {
                    f(fd, ::buffa_descriptor::reflect::ReflectMessage::get(self, fd));
                }
            }
        }
        fn to_dynamic(&self) -> ::buffa_descriptor::reflect::DynamicMessage {
            ::buffa_descriptor::reflect::DynamicMessage::from_message(
                self,
                ::buffa::alloc::sync::Arc::clone(__buffa::reflect::descriptor_pool()),
                Self::__buffa_reflect_message_index(),
            )
        }
    }
    impl ::buffa_descriptor::reflect::ReflectElement for FieldMask {
        #[inline]
        fn as_value_ref(&self) -> ::buffa_descriptor::reflect::ValueRef<'_> {
            ::buffa_descriptor::reflect::ValueRef::Message(
                ::buffa_descriptor::reflect::ReflectCow::Borrowed(self),
            )
        }
    }
    impl FieldMask {
        /// Memoized `MessageIndex` for this message type, resolved once
        /// against the package's embedded descriptor pool.
        #[doc(hidden)]
        fn __buffa_reflect_message_index() -> ::buffa_descriptor::MessageIndex {
            static IDX: ::std::sync::OnceLock<::buffa_descriptor::MessageIndex> = ::std::sync::OnceLock::new();
            *IDX
                .get_or_init(|| {
                    __buffa::reflect::descriptor_pool()
                        .message_index(<Self as ::buffa::MessageName>::FULL_NAME)
                        .expect(
                            "generated message is registered in the embedded descriptor pool",
                        )
                })
        }
    }
    impl ::buffa_descriptor::reflect::Reflectable for FieldMask {
        /// Vtable-mode reflective handle: borrows `self` directly. No
        /// encode/decode round-trip and no allocation — the reflective
        /// accessors read this message's fields in place.
        #[inline]
        fn reflect(&self) -> ::buffa_descriptor::reflect::ReflectCow<'_> {
            ::buffa_descriptor::reflect::ReflectCow::Borrowed(self)
        }
    }
};
impl ::buffa::MessageName for FieldMask {
    const PACKAGE: &'static str = "google.protobuf";
    const NAME: &'static str = "FieldMask";
    const FULL_NAME: &'static str = "google.protobuf.FieldMask";
    const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.FieldMask";
}
impl ::buffa::Message for FieldMask {
    /// Returns the total encoded size in bytes.
    ///
    /// The result is a `u32`; the protobuf specification requires all
    /// messages to fit within 2 GiB (2,147,483,647 bytes), so a
    /// compliant message will never overflow this type.
    #[allow(clippy::let_and_return)]
    fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 {
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        let mut size = 0u32;
        for v in &self.paths {
            size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
        }
        size += self.__buffa_unknown_fields.encoded_len() as u32;
        size
    }
    fn write_to(
        &self,
        _cache: &mut ::buffa::SizeCache,
        buf: &mut impl ::buffa::bytes::BufMut,
    ) {
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        for v in &self.paths {
            ::buffa::encoding::Tag::new(
                    1u32,
                    ::buffa::encoding::WireType::LengthDelimited,
                )
                .encode(buf);
            ::buffa::types::encode_string(v, buf);
        }
        self.__buffa_unknown_fields.write_to(buf);
    }
    fn merge_field(
        &mut self,
        tag: ::buffa::encoding::Tag,
        buf: &mut impl ::buffa::bytes::Buf,
        depth: u32,
    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
        #[allow(unused_imports)]
        use ::buffa::bytes::Buf as _;
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        match tag.field_number() {
            1u32 => {
                if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
                        field_number: 1u32,
                        expected: 2u8,
                        actual: tag.wire_type() as u8,
                    });
                }
                self.paths.push(::buffa::types::decode_string(buf)?);
            }
            _ => {
                self.__buffa_unknown_fields
                    .push(::buffa::encoding::decode_unknown_field(tag, buf, depth)?);
            }
        }
        ::core::result::Result::Ok(())
    }
    fn clear(&mut self) {
        self.paths.clear();
        self.__buffa_unknown_fields.clear();
    }
}
impl ::buffa::ExtensionSet for FieldMask {
    const PROTO_FQN: &'static str = "google.protobuf.FieldMask";
    fn unknown_fields(&self) -> &::buffa::UnknownFields {
        &self.__buffa_unknown_fields
    }
    fn unknown_fields_mut(&mut self) -> &mut ::buffa::UnknownFields {
        &mut self.__buffa_unknown_fields
    }
}
impl ::buffa::text::TextFormat for FieldMask {
    fn encode_text(
        &self,
        enc: &mut ::buffa::text::TextEncoder<'_>,
    ) -> ::core::fmt::Result {
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        for __v in &self.paths {
            enc.write_field_name("paths")?;
            enc.write_string(__v)?;
        }
        enc.write_unknown_fields(&self.__buffa_unknown_fields)?;
        ::core::result::Result::Ok(())
    }
    fn merge_text(
        &mut self,
        dec: &mut ::buffa::text::TextDecoder<'_>,
    ) -> ::core::result::Result<(), ::buffa::text::ParseError> {
        #[allow(unused_imports)]
        use ::buffa::Enumeration as _;
        while let ::core::option::Option::Some(__name) = dec.read_field_name()? {
            match __name {
                "paths" => {
                    dec.read_repeated_into(
                        &mut self.paths,
                        |__d| ::core::result::Result::Ok(__d.read_string()?.into_owned()),
                    )?
                }
                _ => dec.skip_value()?,
            }
        }
        ::core::result::Result::Ok(())
    }
}
#[doc(hidden)]
pub const __FIELD_MASK_TEXT_ANY: ::buffa::type_registry::TextAnyEntry = ::buffa::type_registry::TextAnyEntry {
    type_url: "type.googleapis.com/google.protobuf.FieldMask",
    text_encode: ::buffa::type_registry::any_encode_text::<FieldMask>,
    text_merge: ::buffa::type_registry::any_merge_text::<FieldMask>,
};
