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