buffa_types/generated/
google.protobuf.any.rs1#[derive(Clone, PartialEq, Default)]
5#[cfg_attr(feature = "arbitrary", derive(::arbitrary::Arbitrary))]
6pub struct Any {
7 pub type_url: ::buffa::alloc::string::String,
9 pub value: ::buffa::alloc::vec::Vec<u8>,
11 #[doc(hidden)]
12 pub __buffa_unknown_fields: ::buffa::UnknownFields,
13 #[doc(hidden)]
14 pub __buffa_cached_size: ::buffa::__private::CachedSize,
15}
16impl ::core::fmt::Debug for Any {
17 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
18 f.debug_struct("Any")
19 .field("type_url", &self.type_url)
20 .field("value", &self.value)
21 .finish()
22 }
23}
24impl Any {
25 pub const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.Any";
30}
31unsafe impl ::buffa::DefaultInstance for Any {
32 fn default_instance() -> &'static Self {
33 static VALUE: ::buffa::__private::OnceBox<Any> = ::buffa::__private::OnceBox::new();
34 VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Any::default()))
35 }
36}
37impl ::buffa::Message for Any {
38 fn compute_size(&self) -> u32 {
44 #[allow(unused_imports)]
45 use ::buffa::Enumeration as _;
46 let mut size = 0u32;
47 if !self.type_url.is_empty() {
48 size += 1u32 + ::buffa::types::string_encoded_len(&self.type_url) as u32;
49 }
50 if !self.value.is_empty() {
51 size += 1u32 + ::buffa::types::bytes_encoded_len(&self.value) as u32;
52 }
53 size += self.__buffa_unknown_fields.encoded_len() as u32;
54 self.__buffa_cached_size.set(size);
55 size
56 }
57 fn write_to(&self, buf: &mut impl ::buffa::bytes::BufMut) {
58 #[allow(unused_imports)]
59 use ::buffa::Enumeration as _;
60 if !self.type_url.is_empty() {
61 ::buffa::encoding::Tag::new(
62 1u32,
63 ::buffa::encoding::WireType::LengthDelimited,
64 )
65 .encode(buf);
66 ::buffa::types::encode_string(&self.type_url, buf);
67 }
68 if !self.value.is_empty() {
69 ::buffa::encoding::Tag::new(
70 2u32,
71 ::buffa::encoding::WireType::LengthDelimited,
72 )
73 .encode(buf);
74 ::buffa::types::encode_bytes(&self.value, buf);
75 }
76 self.__buffa_unknown_fields.write_to(buf);
77 }
78 fn merge_field(
79 &mut self,
80 tag: ::buffa::encoding::Tag,
81 buf: &mut impl ::buffa::bytes::Buf,
82 depth: u32,
83 ) -> ::core::result::Result<(), ::buffa::DecodeError> {
84 #[allow(unused_imports)]
85 use ::buffa::bytes::Buf as _;
86 #[allow(unused_imports)]
87 use ::buffa::Enumeration as _;
88 match tag.field_number() {
89 1u32 => {
90 if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
91 return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
92 field_number: 1u32,
93 expected: 2u8,
94 actual: tag.wire_type() as u8,
95 });
96 }
97 ::buffa::types::merge_string(&mut self.type_url, buf)?;
98 }
99 2u32 => {
100 if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
101 return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
102 field_number: 2u32,
103 expected: 2u8,
104 actual: tag.wire_type() as u8,
105 });
106 }
107 ::buffa::types::merge_bytes(&mut self.value, buf)?;
108 }
109 _ => {
110 self.__buffa_unknown_fields
111 .push(::buffa::encoding::decode_unknown_field(tag, buf, depth)?);
112 }
113 }
114 ::core::result::Result::Ok(())
115 }
116 fn cached_size(&self) -> u32 {
117 self.__buffa_cached_size.get()
118 }
119 fn clear(&mut self) {
120 self.type_url.clear();
121 self.value.clear();
122 self.__buffa_unknown_fields.clear();
123 self.__buffa_cached_size.set(0);
124 }
125}
126#[derive(Clone, Debug, Default)]
127pub struct AnyView<'a> {
128 pub type_url: &'a str,
130 pub value: &'a [u8],
132 pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
133}
134impl<'a> AnyView<'a> {
135 #[doc(hidden)]
143 pub fn _decode_depth(
144 buf: &'a [u8],
145 depth: u32,
146 ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
147 let mut view = Self::default();
148 view._merge_into_view(buf, depth)?;
149 ::core::result::Result::Ok(view)
150 }
151 #[doc(hidden)]
159 pub fn _merge_into_view(
160 &mut self,
161 buf: &'a [u8],
162 depth: u32,
163 ) -> ::core::result::Result<(), ::buffa::DecodeError> {
164 let _ = depth;
165 #[allow(unused_variables)]
166 let view = self;
167 let mut cur: &'a [u8] = buf;
168 while !cur.is_empty() {
169 let before_tag = cur;
170 let tag = ::buffa::encoding::Tag::decode(&mut cur)?;
171 match tag.field_number() {
172 1u32 => {
173 if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
174 return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
175 field_number: 1u32,
176 expected: 2u8,
177 actual: tag.wire_type() as u8,
178 });
179 }
180 view.type_url = ::buffa::types::borrow_str(&mut cur)?;
181 }
182 2u32 => {
183 if tag.wire_type() != ::buffa::encoding::WireType::LengthDelimited {
184 return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
185 field_number: 2u32,
186 expected: 2u8,
187 actual: tag.wire_type() as u8,
188 });
189 }
190 view.value = ::buffa::types::borrow_bytes(&mut cur)?;
191 }
192 _ => {
193 ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?;
194 let span_len = before_tag.len() - cur.len();
195 view.__buffa_unknown_fields.push_raw(&before_tag[..span_len]);
196 }
197 }
198 }
199 ::core::result::Result::Ok(())
200 }
201}
202impl<'a> ::buffa::MessageView<'a> for AnyView<'a> {
203 type Owned = Any;
204 fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
205 Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT)
206 }
207 fn decode_view_with_limit(
208 buf: &'a [u8],
209 depth: u32,
210 ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
211 Self::_decode_depth(buf, depth)
212 }
213 #[allow(clippy::redundant_closure)]
215 fn to_owned_message(&self) -> Any {
216 #[allow(unused_imports)]
217 use ::buffa::alloc::string::ToString as _;
218 Any {
219 type_url: self.type_url.to_string(),
220 value: (self.value).to_vec(),
221 __buffa_unknown_fields: self
222 .__buffa_unknown_fields
223 .to_owned()
224 .unwrap_or_default(),
225 ..::core::default::Default::default()
226 }
227 }
228}
229unsafe impl ::buffa::DefaultViewInstance for AnyView<'static> {
230 fn default_view_instance() -> &'static Self {
231 static VALUE: ::buffa::__private::OnceBox<AnyView<'static>> = ::buffa::__private::OnceBox::new();
232 VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(AnyView::default()))
233 }
234}
235unsafe impl<'a> ::buffa::HasDefaultViewInstance for AnyView<'a> {
236 type Static = AnyView<'static>;
237}