Skip to main content

buffa_types/generated/
google.protobuf.empty.rs

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