buffa_types/generated/
google.protobuf.duration.rs1#[derive(Clone, PartialEq, Default)]
69#[cfg_attr(feature = "arbitrary", derive(::arbitrary::Arbitrary))]
70pub struct Duration {
71 pub seconds: i64,
77 pub nanos: i32,
86 #[doc(hidden)]
87 pub __buffa_unknown_fields: ::buffa::UnknownFields,
88}
89impl ::core::fmt::Debug for Duration {
90 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
91 f.debug_struct("Duration")
92 .field("seconds", &self.seconds)
93 .field("nanos", &self.nanos)
94 .finish()
95 }
96}
97impl Duration {
98 pub const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.Duration";
103}
104impl ::buffa::DefaultInstance for Duration {
105 fn default_instance() -> &'static Self {
106 static VALUE: ::buffa::__private::OnceBox<Duration> = ::buffa::__private::OnceBox::new();
107 VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Self::default()))
108 }
109}
110#[cfg(feature = "reflect")]
111const _: () = {
112 impl ::buffa_descriptor::reflect::ReflectMessage for Duration {
113 fn message_descriptor(&self) -> &::buffa_descriptor::MessageDescriptor {
114 __buffa::reflect::descriptor_pool()
115 .message(Self::__buffa_reflect_message_index())
116 }
117 fn pool(
118 &self,
119 ) -> &::buffa::alloc::sync::Arc<::buffa_descriptor::DescriptorPool> {
120 __buffa::reflect::descriptor_pool()
121 }
122 fn unknown_fields(&self) -> &::buffa::UnknownFields {
123 &self.__buffa_unknown_fields
124 }
125 fn get(
126 &self,
127 field: &::buffa_descriptor::FieldDescriptor,
128 ) -> ::buffa_descriptor::reflect::ValueRef<'_> {
129 #[allow(unused_imports)]
130 use ::buffa::Enumeration as _;
131 match field.number() {
132 1u32 => ::buffa_descriptor::reflect::ValueRef::I64(self.seconds),
133 2u32 => ::buffa_descriptor::reflect::ValueRef::I32(self.nanos),
134 _ => {
135 ::core::debug_assert!(
136 false,
137 "field number {} is not a member of this message's reflect get()",
138 field.number(),
139 );
140 ::buffa_descriptor::reflect::ValueRef::Bool(false)
141 }
142 }
143 }
144 fn has(&self, field: &::buffa_descriptor::FieldDescriptor) -> bool {
145 match field.number() {
146 1u32 => self.seconds != 0,
147 2u32 => self.nanos != 0,
148 _ => false,
149 }
150 }
151 fn for_each_set(
152 &self,
153 f: &mut dyn ::core::ops::FnMut(
154 &::buffa_descriptor::FieldDescriptor,
155 ::buffa_descriptor::reflect::ValueRef<'_>,
156 ),
157 ) {
158 let md = ::buffa_descriptor::reflect::ReflectMessage::message_descriptor(
159 self,
160 );
161 for fd in md.fields() {
162 if ::buffa_descriptor::reflect::ReflectMessage::has(self, fd) {
163 f(fd, ::buffa_descriptor::reflect::ReflectMessage::get(self, fd));
164 }
165 }
166 }
167 fn to_dynamic(&self) -> ::buffa_descriptor::reflect::DynamicMessage {
168 ::buffa_descriptor::reflect::DynamicMessage::from_message(
169 self,
170 ::buffa::alloc::sync::Arc::clone(__buffa::reflect::descriptor_pool()),
171 Self::__buffa_reflect_message_index(),
172 )
173 }
174 }
175 impl ::buffa_descriptor::reflect::ReflectElement for Duration {
176 #[inline]
177 fn as_value_ref(&self) -> ::buffa_descriptor::reflect::ValueRef<'_> {
178 ::buffa_descriptor::reflect::ValueRef::Message(
179 ::buffa_descriptor::reflect::ReflectCow::Borrowed(self),
180 )
181 }
182 }
183 impl Duration {
184 #[doc(hidden)]
187 fn __buffa_reflect_message_index() -> ::buffa_descriptor::MessageIndex {
188 static IDX: ::std::sync::OnceLock<::buffa_descriptor::MessageIndex> = ::std::sync::OnceLock::new();
189 *IDX
190 .get_or_init(|| {
191 __buffa::reflect::descriptor_pool()
192 .message_index(<Self as ::buffa::MessageName>::FULL_NAME)
193 .expect(
194 "generated message is registered in the embedded descriptor pool",
195 )
196 })
197 }
198 }
199 impl ::buffa_descriptor::reflect::Reflectable for Duration {
200 #[inline]
204 fn reflect(&self) -> ::buffa_descriptor::reflect::ReflectCow<'_> {
205 ::buffa_descriptor::reflect::ReflectCow::Borrowed(self)
206 }
207 }
208};
209impl ::buffa::MessageName for Duration {
210 const PACKAGE: &'static str = "google.protobuf";
211 const NAME: &'static str = "Duration";
212 const FULL_NAME: &'static str = "google.protobuf.Duration";
213 const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.Duration";
214}
215impl ::buffa::Message for Duration {
216 #[allow(clippy::let_and_return)]
222 fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 {
223 #[allow(unused_imports)]
224 use ::buffa::Enumeration as _;
225 let mut size = 0u32;
226 if self.seconds != 0i64 {
227 size += 1u32 + ::buffa::types::int64_encoded_len(self.seconds) as u32;
228 }
229 if self.nanos != 0i32 {
230 size += 1u32 + ::buffa::types::int32_encoded_len(self.nanos) as u32;
231 }
232 size += self.__buffa_unknown_fields.encoded_len() as u32;
233 size
234 }
235 fn write_to(
236 &self,
237 _cache: &mut ::buffa::SizeCache,
238 buf: &mut impl ::buffa::bytes::BufMut,
239 ) {
240 #[allow(unused_imports)]
241 use ::buffa::Enumeration as _;
242 if self.seconds != 0i64 {
243 ::buffa::encoding::Tag::new(1u32, ::buffa::encoding::WireType::Varint)
244 .encode(buf);
245 ::buffa::types::encode_int64(self.seconds, buf);
246 }
247 if self.nanos != 0i32 {
248 ::buffa::encoding::Tag::new(2u32, ::buffa::encoding::WireType::Varint)
249 .encode(buf);
250 ::buffa::types::encode_int32(self.nanos, buf);
251 }
252 self.__buffa_unknown_fields.write_to(buf);
253 }
254 fn merge_field(
255 &mut self,
256 tag: ::buffa::encoding::Tag,
257 buf: &mut impl ::buffa::bytes::Buf,
258 depth: u32,
259 ) -> ::core::result::Result<(), ::buffa::DecodeError> {
260 #[allow(unused_imports)]
261 use ::buffa::bytes::Buf as _;
262 #[allow(unused_imports)]
263 use ::buffa::Enumeration as _;
264 match tag.field_number() {
265 1u32 => {
266 if tag.wire_type() != ::buffa::encoding::WireType::Varint {
267 return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
268 field_number: 1u32,
269 expected: 0u8,
270 actual: tag.wire_type() as u8,
271 });
272 }
273 self.seconds = ::buffa::types::decode_int64(buf)?;
274 }
275 2u32 => {
276 if tag.wire_type() != ::buffa::encoding::WireType::Varint {
277 return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
278 field_number: 2u32,
279 expected: 0u8,
280 actual: tag.wire_type() as u8,
281 });
282 }
283 self.nanos = ::buffa::types::decode_int32(buf)?;
284 }
285 _ => {
286 self.__buffa_unknown_fields
287 .push(::buffa::encoding::decode_unknown_field(tag, buf, depth)?);
288 }
289 }
290 ::core::result::Result::Ok(())
291 }
292 fn clear(&mut self) {
293 self.seconds = 0i64;
294 self.nanos = 0i32;
295 self.__buffa_unknown_fields.clear();
296 }
297}
298impl ::buffa::ExtensionSet for Duration {
299 const PROTO_FQN: &'static str = "google.protobuf.Duration";
300 fn unknown_fields(&self) -> &::buffa::UnknownFields {
301 &self.__buffa_unknown_fields
302 }
303 fn unknown_fields_mut(&mut self) -> &mut ::buffa::UnknownFields {
304 &mut self.__buffa_unknown_fields
305 }
306}
307impl ::buffa::text::TextFormat for Duration {
308 fn encode_text(
309 &self,
310 enc: &mut ::buffa::text::TextEncoder<'_>,
311 ) -> ::core::fmt::Result {
312 #[allow(unused_imports)]
313 use ::buffa::Enumeration as _;
314 if self.seconds != 0i64 {
315 enc.write_field_name("seconds")?;
316 enc.write_i64(self.seconds)?;
317 }
318 if self.nanos != 0i32 {
319 enc.write_field_name("nanos")?;
320 enc.write_i32(self.nanos)?;
321 }
322 enc.write_unknown_fields(&self.__buffa_unknown_fields)?;
323 ::core::result::Result::Ok(())
324 }
325 fn merge_text(
326 &mut self,
327 dec: &mut ::buffa::text::TextDecoder<'_>,
328 ) -> ::core::result::Result<(), ::buffa::text::ParseError> {
329 #[allow(unused_imports)]
330 use ::buffa::Enumeration as _;
331 while let ::core::option::Option::Some(__name) = dec.read_field_name()? {
332 match __name {
333 "seconds" => self.seconds = dec.read_i64()?,
334 "nanos" => self.nanos = dec.read_i32()?,
335 _ => dec.skip_value()?,
336 }
337 }
338 ::core::result::Result::Ok(())
339 }
340}
341#[doc(hidden)]
342pub const __DURATION_TEXT_ANY: ::buffa::type_registry::TextAnyEntry = ::buffa::type_registry::TextAnyEntry {
343 type_url: "type.googleapis.com/google.protobuf.Duration",
344 text_encode: ::buffa::type_registry::any_encode_text::<Duration>,
345 text_merge: ::buffa::type_registry::any_merge_text::<Duration>,
346};