Skip to main content

buffa_types/generated/
google.protobuf.field_mask.rs

1// @generated by protoc-gen-buffa. DO NOT EDIT.
2// source: google/protobuf/field_mask.proto
3
4#[derive(Clone, PartialEq, Default)]
5#[cfg_attr(feature = "arbitrary", derive(::arbitrary::Arbitrary))]
6pub struct FieldMask {
7    ///Field 1: `paths`
8    pub paths: ::buffa::alloc::vec::Vec<::buffa::alloc::string::String>,
9    #[doc(hidden)]
10    pub __buffa_unknown_fields: ::buffa::UnknownFields,
11    #[doc(hidden)]
12    pub __buffa_cached_size: ::buffa::__private::CachedSize,
13}
14impl ::core::fmt::Debug for FieldMask {
15    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
16        f.debug_struct("FieldMask").field("paths", &self.paths).finish()
17    }
18}
19impl FieldMask {
20    /// Protobuf type URL for this message, for use with `Any::pack` and
21    /// `Any::unpack_if`.
22    ///
23    /// Format: `type.googleapis.com/<fully.qualified.TypeName>`
24    pub const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.FieldMask";
25}
26unsafe impl ::buffa::DefaultInstance for FieldMask {
27    fn default_instance() -> &'static Self {
28        static VALUE: ::buffa::__private::OnceBox<FieldMask> = ::buffa::__private::OnceBox::new();
29        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(FieldMask::default()))
30    }
31}
32impl ::buffa::Message for FieldMask {
33    /// Returns the total encoded size in bytes.
34    ///
35    /// The result is a `u32`; the protobuf specification requires all
36    /// messages to fit within 2 GiB (2,147,483,647 bytes), so a
37    /// compliant message will never overflow this type.
38    fn compute_size(&self) -> u32 {
39        #[allow(unused_imports)]
40        use ::buffa::Enumeration as _;
41        let mut size = 0u32;
42        for v in &self.paths {
43            size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
44        }
45        size += self.__buffa_unknown_fields.encoded_len() as u32;
46        self.__buffa_cached_size.set(size);
47        size
48    }
49    fn write_to(&self, buf: &mut impl ::buffa::bytes::BufMut) {
50        #[allow(unused_imports)]
51        use ::buffa::Enumeration as _;
52        for v in &self.paths {
53            ::buffa::encoding::Tag::new(
54                    1u32,
55                    ::buffa::encoding::WireType::LengthDelimited,
56                )
57                .encode(buf);
58            ::buffa::types::encode_string(v, buf);
59        }
60        self.__buffa_unknown_fields.write_to(buf);
61    }
62    fn merge_field(
63        &mut self,
64        tag: ::buffa::encoding::Tag,
65        buf: &mut impl ::buffa::bytes::Buf,
66        depth: u32,
67    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
68        #[allow(unused_imports)]
69        use ::buffa::bytes::Buf as _;
70        #[allow(unused_imports)]
71        use ::buffa::Enumeration as _;
72        match tag.field_number() {
73            1u32 => {
74                if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
75                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
76                        field_number: 1u32,
77                        expected: 2u8,
78                        actual: tag.wire_type() as u8,
79                    });
80                }
81                self.paths.push(::buffa::types::decode_string(buf)?);
82            }
83            _ => {
84                self.__buffa_unknown_fields
85                    .push(::buffa::encoding::decode_unknown_field(tag, buf, depth)?);
86            }
87        }
88        ::core::result::Result::Ok(())
89    }
90    fn cached_size(&self) -> u32 {
91        self.__buffa_cached_size.get()
92    }
93    fn clear(&mut self) {
94        self.paths.clear();
95        self.__buffa_unknown_fields.clear();
96        self.__buffa_cached_size.set(0);
97    }
98}
99#[derive(Clone, Debug, Default)]
100pub struct FieldMaskView<'a> {
101    ///Field 1: `paths`
102    pub paths: ::buffa::RepeatedView<'a, &'a str>,
103    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
104}
105impl<'a> FieldMaskView<'a> {
106    /// Decode from `buf`, enforcing a recursion depth limit for nested messages.
107    ///
108    /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`]
109    /// and by generated sub-message decode arms with `depth - 1`.
110    ///
111    /// **Not part of the public API.** Named with a leading underscore to
112    /// signal that it is for generated-code use only.
113    #[doc(hidden)]
114    pub fn _decode_depth(
115        buf: &'a [u8],
116        depth: u32,
117    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
118        let mut view = Self::default();
119        view._merge_into_view(buf, depth)?;
120        ::core::result::Result::Ok(view)
121    }
122    /// Merge fields from `buf` into this view (proto merge semantics).
123    ///
124    /// Repeated fields append; singular fields last-wins; singular
125    /// MESSAGE fields merge recursively. Used by sub-message decode
126    /// arms when the same field appears multiple times on the wire.
127    ///
128    /// **Not part of the public API.**
129    #[doc(hidden)]
130    pub fn _merge_into_view(
131        &mut self,
132        buf: &'a [u8],
133        depth: u32,
134    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
135        let _ = depth;
136        #[allow(unused_variables)]
137        let view = self;
138        let mut cur: &'a [u8] = buf;
139        while !cur.is_empty() {
140            let before_tag = cur;
141            let tag = ::buffa::encoding::Tag::decode(&mut cur)?;
142            match tag.field_number() {
143                1u32 => {
144                    if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
145                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
146                            field_number: 1u32,
147                            expected: 2u8,
148                            actual: tag.wire_type() as u8,
149                        });
150                    }
151                    view.paths.push(::buffa::types::borrow_str(&mut cur)?);
152                }
153                _ => {
154                    ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?;
155                    let span_len = before_tag.len() - cur.len();
156                    view.__buffa_unknown_fields.push_raw(&before_tag[..span_len]);
157                }
158            }
159        }
160        ::core::result::Result::Ok(())
161    }
162}
163impl<'a> ::buffa::MessageView<'a> for FieldMaskView<'a> {
164    type Owned = FieldMask;
165    fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
166        Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT)
167    }
168    fn decode_view_with_limit(
169        buf: &'a [u8],
170        depth: u32,
171    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
172        Self::_decode_depth(buf, depth)
173    }
174    /// Convert this view to the owned message type.
175    #[allow(clippy::redundant_closure)]
176    fn to_owned_message(&self) -> FieldMask {
177        #[allow(unused_imports)]
178        use ::buffa::alloc::string::ToString as _;
179        FieldMask {
180            paths: self.paths.iter().map(|s| s.to_string()).collect(),
181            __buffa_unknown_fields: self
182                .__buffa_unknown_fields
183                .to_owned()
184                .unwrap_or_default(),
185            ..::core::default::Default::default()
186        }
187    }
188}
189unsafe impl ::buffa::DefaultViewInstance for FieldMaskView<'static> {
190    fn default_view_instance() -> &'static Self {
191        static VALUE: ::buffa::__private::OnceBox<FieldMaskView<'static>> = ::buffa::__private::OnceBox::new();
192        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(FieldMaskView::default()))
193    }
194}
195unsafe impl<'a> ::buffa::HasDefaultViewInstance for FieldMaskView<'a> {
196    type Static = FieldMaskView<'static>;
197}