buffa_types/generated/
google.protobuf.empty.__view.rs1#[derive(Clone, Debug, Default)]
14pub struct EmptyView<'a> {
15 pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
16}
17impl<'a> EmptyView<'a> {
18 #[doc(hidden)]
26 pub fn _decode_depth(
27 buf: &'a [u8],
28 depth: u32,
29 ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
30 let mut view = Self::default();
31 view._merge_into_view(buf, depth)?;
32 ::core::result::Result::Ok(view)
33 }
34 #[doc(hidden)]
42 pub fn _merge_into_view(
43 &mut self,
44 buf: &'a [u8],
45 depth: u32,
46 ) -> ::core::result::Result<(), ::buffa::DecodeError> {
47 let _ = depth;
48 #[allow(unused_variables)]
49 let view = self;
50 let mut cur: &'a [u8] = buf;
51 while !cur.is_empty() {
52 let before_tag = cur;
53 let tag = ::buffa::encoding::Tag::decode(&mut cur)?;
54 match tag.field_number() {
55 _ => {
56 ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?;
57 let span_len = before_tag.len() - cur.len();
58 view.__buffa_unknown_fields.push_raw(&before_tag[..span_len]);
59 }
60 }
61 }
62 ::core::result::Result::Ok(())
63 }
64}
65impl<'a> ::buffa::MessageView<'a> for EmptyView<'a> {
66 type Owned = super::super::Empty;
67 fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
68 Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT)
69 }
70 fn decode_view_with_limit(
71 buf: &'a [u8],
72 depth: u32,
73 ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
74 Self::_decode_depth(buf, depth)
75 }
76 fn to_owned_message(&self) -> super::super::Empty {
77 self.to_owned_from_source(None)
78 }
79 #[allow(clippy::useless_conversion, clippy::needless_update)]
80 fn to_owned_from_source(
81 &self,
82 __buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>,
83 ) -> super::super::Empty {
84 #[allow(unused_imports)]
85 use ::buffa::alloc::string::ToString as _;
86 let _ = __buffa_src;
87 super::super::Empty {
88 __buffa_unknown_fields: self
89 .__buffa_unknown_fields
90 .to_owned()
91 .unwrap_or_default()
92 .into(),
93 ..::core::default::Default::default()
94 }
95 }
96}
97impl<'a> ::buffa::ViewEncode<'a> for EmptyView<'a> {
98 #[allow(clippy::needless_borrow, clippy::let_and_return)]
99 fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 {
100 #[allow(unused_imports)]
101 use ::buffa::Enumeration as _;
102 let mut size = 0u32;
103 size += self.__buffa_unknown_fields.encoded_len() as u32;
104 size
105 }
106 #[allow(clippy::needless_borrow)]
107 fn write_to(
108 &self,
109 _cache: &mut ::buffa::SizeCache,
110 buf: &mut impl ::buffa::bytes::BufMut,
111 ) {
112 #[allow(unused_imports)]
113 use ::buffa::Enumeration as _;
114 self.__buffa_unknown_fields.write_to(buf);
115 }
116}
117impl<'a> ::buffa::MessageName for EmptyView<'a> {
118 const PACKAGE: &'static str = "google.protobuf";
119 const NAME: &'static str = "Empty";
120 const FULL_NAME: &'static str = "google.protobuf.Empty";
121 const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.Empty";
122}
123impl<'v> ::buffa::DefaultViewInstance for EmptyView<'v> {
124 fn default_view_instance<'a>() -> &'a Self
125 where
126 Self: 'a,
127 {
128 static VALUE: ::buffa::__private::OnceBox<EmptyView<'static>> = ::buffa::__private::OnceBox::new();
129 VALUE
130 .get_or_init(|| ::buffa::alloc::boxed::Box::new(
131 <EmptyView<'static>>::default(),
132 ))
133 }
134}
135impl ::buffa::ViewReborrow for EmptyView<'static> {
136 type Reborrowed<'b> = EmptyView<'b>;
137 fn reborrow<'b>(this: &'b Self) -> &'b Self::Reborrowed<'b> {
138 this
139 }
140}
141#[derive(Clone, Debug)]
147pub struct EmptyOwnedView(::buffa::OwnedView<EmptyView<'static>>);
148impl EmptyOwnedView {
149 pub fn decode(
159 bytes: ::buffa::bytes::Bytes,
160 ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
161 ::core::result::Result::Ok(EmptyOwnedView(::buffa::OwnedView::decode(bytes)?))
162 }
163 pub fn decode_with_options(
171 bytes: ::buffa::bytes::Bytes,
172 opts: &::buffa::DecodeOptions,
173 ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
174 ::core::result::Result::Ok(
175 EmptyOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
176 )
177 }
178 pub fn from_owned(
185 msg: &super::super::Empty,
186 ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
187 ::core::result::Result::Ok(EmptyOwnedView(::buffa::OwnedView::from_owned(msg)?))
188 }
189 #[must_use]
191 pub fn view(&self) -> &EmptyView<'_> {
192 self.0.reborrow()
193 }
194 #[must_use]
196 pub fn to_owned_message(&self) -> super::super::Empty {
197 self.0.to_owned_message()
198 }
199 #[must_use]
201 pub fn bytes(&self) -> &::buffa::bytes::Bytes {
202 self.0.bytes()
203 }
204 #[must_use]
206 pub fn into_bytes(self) -> ::buffa::bytes::Bytes {
207 self.0.into_bytes()
208 }
209}
210impl ::core::convert::From<::buffa::OwnedView<EmptyView<'static>>> for EmptyOwnedView {
211 fn from(inner: ::buffa::OwnedView<EmptyView<'static>>) -> Self {
212 EmptyOwnedView(inner)
213 }
214}
215impl ::core::convert::From<EmptyOwnedView> for ::buffa::OwnedView<EmptyView<'static>> {
216 fn from(wrapper: EmptyOwnedView) -> Self {
217 wrapper.0
218 }
219}
220impl ::core::convert::AsRef<::buffa::OwnedView<EmptyView<'static>>> for EmptyOwnedView {
221 fn as_ref(&self) -> &::buffa::OwnedView<EmptyView<'static>> {
222 &self.0
223 }
224}
225impl ::buffa::HasMessageView for super::super::Empty {
226 type View<'a> = EmptyView<'a>;
227 type ViewHandle = EmptyOwnedView;
228}
229#[cfg(feature = "reflect")]
230const _: () = {
231 impl<'a> ::buffa_descriptor::reflect::ReflectMessage for EmptyView<'a> {
232 fn message_descriptor(&self) -> &::buffa_descriptor::MessageDescriptor {
233 super::super::__buffa::reflect::descriptor_pool()
234 .message(Self::__buffa_reflect_message_index())
235 }
236 fn pool(
237 &self,
238 ) -> &::buffa::alloc::sync::Arc<::buffa_descriptor::DescriptorPool> {
239 super::super::__buffa::reflect::descriptor_pool()
240 }
241 fn get(
242 &self,
243 field: &::buffa_descriptor::FieldDescriptor,
244 ) -> ::buffa_descriptor::reflect::ValueRef<'_> {
245 #[allow(unused_imports)]
246 use ::buffa::Enumeration as _;
247 match field.number() {
248 _ => {
249 ::core::debug_assert!(
250 false,
251 "field number {} is not a member of this view's reflect get()",
252 field.number(),
253 );
254 ::buffa_descriptor::reflect::ValueRef::Bool(false)
255 }
256 }
257 }
258 fn has(&self, field: &::buffa_descriptor::FieldDescriptor) -> bool {
259 match field.number() {
260 _ => false,
261 }
262 }
263 fn for_each_set(
264 &self,
265 f: &mut dyn ::core::ops::FnMut(
266 &::buffa_descriptor::FieldDescriptor,
267 ::buffa_descriptor::reflect::ValueRef<'_>,
268 ),
269 ) {
270 let md = ::buffa_descriptor::reflect::ReflectMessage::message_descriptor(
271 self,
272 );
273 for fd in md.fields() {
274 if ::buffa_descriptor::reflect::ReflectMessage::has(self, fd) {
275 f(fd, ::buffa_descriptor::reflect::ReflectMessage::get(self, fd));
276 }
277 }
278 }
279 fn to_dynamic(&self) -> ::buffa_descriptor::reflect::DynamicMessage {
280 let bytes = ::buffa::ViewEncode::encode_to_vec(self);
281 ::buffa_descriptor::reflect::DynamicMessage::decode(
282 ::buffa::alloc::sync::Arc::clone(
283 super::super::__buffa::reflect::descriptor_pool(),
284 ),
285 Self::__buffa_reflect_message_index(),
286 &bytes,
287 )
288 .expect("view re-encodes to bytes decodable against its own descriptor")
289 }
290 }
291 impl<'a> ::buffa_descriptor::reflect::ReflectElement for EmptyView<'a> {
292 fn as_value_ref(&self) -> ::buffa_descriptor::reflect::ValueRef<'_> {
293 ::buffa_descriptor::reflect::ValueRef::Message(
294 ::buffa_descriptor::reflect::ReflectCow::Borrowed(self),
295 )
296 }
297 }
298 impl<'a> EmptyView<'a> {
299 #[doc(hidden)]
304 fn __buffa_reflect_message_index() -> ::buffa_descriptor::MessageIndex {
305 static IDX: ::std::sync::OnceLock<::buffa_descriptor::MessageIndex> = ::std::sync::OnceLock::new();
306 *IDX
307 .get_or_init(|| {
308 super::super::__buffa::reflect::descriptor_pool()
309 .message_index(<Self as ::buffa::MessageName>::FULL_NAME)
310 .expect(
311 "generated view type is registered in the embedded descriptor pool",
312 )
313 })
314 }
315 }
316};