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}