Skip to main content

buffa_types/generated/
google.protobuf.timestamp.rs

1// @generated by protoc-gen-buffa. DO NOT EDIT.
2// source: google/protobuf/timestamp.proto
3
4#[derive(Clone, PartialEq, Default)]
5#[cfg_attr(feature = "arbitrary", derive(::arbitrary::Arbitrary))]
6pub struct Timestamp {
7    ///Field 1: `seconds`
8    pub seconds: i64,
9    ///Field 2: `nanos`
10    pub nanos: i32,
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 Timestamp {
17    fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
18        f.debug_struct("Timestamp")
19            .field("seconds", &self.seconds)
20            .field("nanos", &self.nanos)
21            .finish()
22    }
23}
24impl Timestamp {
25    /// Protobuf type URL for this message, for use with `Any::pack` and
26    /// `Any::unpack_if`.
27    ///
28    /// Format: `type.googleapis.com/<fully.qualified.TypeName>`
29    pub const TYPE_URL: &'static str = "type.googleapis.com/google.protobuf.Timestamp";
30}
31unsafe impl ::buffa::DefaultInstance for Timestamp {
32    fn default_instance() -> &'static Self {
33        static VALUE: ::buffa::__private::OnceBox<Timestamp> = ::buffa::__private::OnceBox::new();
34        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(Timestamp::default()))
35    }
36}
37impl ::buffa::Message for Timestamp {
38    /// Returns the total encoded size in bytes.
39    ///
40    /// The result is a `u32`; the protobuf specification requires all
41    /// messages to fit within 2 GiB (2,147,483,647 bytes), so a
42    /// compliant message will never overflow this type.
43    fn compute_size(&self) -> u32 {
44        #[allow(unused_imports)]
45        use ::buffa::Enumeration as _;
46        let mut size = 0u32;
47        if self.seconds != 0i64 {
48            size += 1u32 + ::buffa::types::int64_encoded_len(self.seconds) as u32;
49        }
50        if self.nanos != 0i32 {
51            size += 1u32 + ::buffa::types::int32_encoded_len(self.nanos) 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.seconds != 0i64 {
61            ::buffa::encoding::Tag::new(1u32, ::buffa::encoding::WireType::Varint)
62                .encode(buf);
63            ::buffa::types::encode_int64(self.seconds, buf);
64        }
65        if self.nanos != 0i32 {
66            ::buffa::encoding::Tag::new(2u32, ::buffa::encoding::WireType::Varint)
67                .encode(buf);
68            ::buffa::types::encode_int32(self.nanos, buf);
69        }
70        self.__buffa_unknown_fields.write_to(buf);
71    }
72    fn merge_field(
73        &mut self,
74        tag: ::buffa::encoding::Tag,
75        buf: &mut impl ::buffa::bytes::Buf,
76        depth: u32,
77    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
78        #[allow(unused_imports)]
79        use ::buffa::bytes::Buf as _;
80        #[allow(unused_imports)]
81        use ::buffa::Enumeration as _;
82        match tag.field_number() {
83            1u32 => {
84                if tag.wire_type() != ::buffa::encoding::WireType::Varint {
85                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
86                        field_number: 1u32,
87                        expected: 0u8,
88                        actual: tag.wire_type() as u8,
89                    });
90                }
91                self.seconds = ::buffa::types::decode_int64(buf)?;
92            }
93            2u32 => {
94                if tag.wire_type() != ::buffa::encoding::WireType::Varint {
95                    return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
96                        field_number: 2u32,
97                        expected: 0u8,
98                        actual: tag.wire_type() as u8,
99                    });
100                }
101                self.nanos = ::buffa::types::decode_int32(buf)?;
102            }
103            _ => {
104                self.__buffa_unknown_fields
105                    .push(::buffa::encoding::decode_unknown_field(tag, buf, depth)?);
106            }
107        }
108        ::core::result::Result::Ok(())
109    }
110    fn cached_size(&self) -> u32 {
111        self.__buffa_cached_size.get()
112    }
113    fn clear(&mut self) {
114        self.seconds = 0i64;
115        self.nanos = 0i32;
116        self.__buffa_unknown_fields.clear();
117        self.__buffa_cached_size.set(0);
118    }
119}
120#[derive(Clone, Debug, Default)]
121pub struct TimestampView<'a> {
122    ///Field 1: `seconds`
123    pub seconds: i64,
124    ///Field 2: `nanos`
125    pub nanos: i32,
126    pub __buffa_unknown_fields: ::buffa::UnknownFieldsView<'a>,
127}
128impl<'a> TimestampView<'a> {
129    /// Decode from `buf`, enforcing a recursion depth limit for nested messages.
130    ///
131    /// Called by [`::buffa::MessageView::decode_view`] with [`::buffa::RECURSION_LIMIT`]
132    /// and by generated sub-message decode arms with `depth - 1`.
133    ///
134    /// **Not part of the public API.** Named with a leading underscore to
135    /// signal that it is for generated-code use only.
136    #[doc(hidden)]
137    pub fn _decode_depth(
138        buf: &'a [u8],
139        depth: u32,
140    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
141        let mut view = Self::default();
142        view._merge_into_view(buf, depth)?;
143        ::core::result::Result::Ok(view)
144    }
145    /// Merge fields from `buf` into this view (proto merge semantics).
146    ///
147    /// Repeated fields append; singular fields last-wins; singular
148    /// MESSAGE fields merge recursively. Used by sub-message decode
149    /// arms when the same field appears multiple times on the wire.
150    ///
151    /// **Not part of the public API.**
152    #[doc(hidden)]
153    pub fn _merge_into_view(
154        &mut self,
155        buf: &'a [u8],
156        depth: u32,
157    ) -> ::core::result::Result<(), ::buffa::DecodeError> {
158        let _ = depth;
159        #[allow(unused_variables)]
160        let view = self;
161        let mut cur: &'a [u8] = buf;
162        while !cur.is_empty() {
163            let before_tag = cur;
164            let tag = ::buffa::encoding::Tag::decode(&mut cur)?;
165            match tag.field_number() {
166                1u32 => {
167                    if tag.wire_type() != ::buffa::encoding::WireType::Varint {
168                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
169                            field_number: 1u32,
170                            expected: 0u8,
171                            actual: tag.wire_type() as u8,
172                        });
173                    }
174                    view.seconds = ::buffa::types::decode_int64(&mut cur)?;
175                }
176                2u32 => {
177                    if tag.wire_type() != ::buffa::encoding::WireType::Varint {
178                        return ::core::result::Result::Err(::buffa::DecodeError::WireTypeMismatch {
179                            field_number: 2u32,
180                            expected: 0u8,
181                            actual: tag.wire_type() as u8,
182                        });
183                    }
184                    view.nanos = ::buffa::types::decode_int32(&mut cur)?;
185                }
186                _ => {
187                    ::buffa::encoding::skip_field_depth(tag, &mut cur, depth)?;
188                    let span_len = before_tag.len() - cur.len();
189                    view.__buffa_unknown_fields.push_raw(&before_tag[..span_len]);
190                }
191            }
192        }
193        ::core::result::Result::Ok(())
194    }
195}
196impl<'a> ::buffa::MessageView<'a> for TimestampView<'a> {
197    type Owned = Timestamp;
198    fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
199        Self::_decode_depth(buf, ::buffa::RECURSION_LIMIT)
200    }
201    fn decode_view_with_limit(
202        buf: &'a [u8],
203        depth: u32,
204    ) -> ::core::result::Result<Self, ::buffa::DecodeError> {
205        Self::_decode_depth(buf, depth)
206    }
207    /// Convert this view to the owned message type.
208    #[allow(clippy::redundant_closure)]
209    fn to_owned_message(&self) -> Timestamp {
210        #[allow(unused_imports)]
211        use ::buffa::alloc::string::ToString as _;
212        Timestamp {
213            seconds: self.seconds,
214            nanos: self.nanos,
215            __buffa_unknown_fields: self
216                .__buffa_unknown_fields
217                .to_owned()
218                .unwrap_or_default(),
219            ..::core::default::Default::default()
220        }
221    }
222}
223unsafe impl ::buffa::DefaultViewInstance for TimestampView<'static> {
224    fn default_view_instance() -> &'static Self {
225        static VALUE: ::buffa::__private::OnceBox<TimestampView<'static>> = ::buffa::__private::OnceBox::new();
226        VALUE.get_or_init(|| ::buffa::alloc::boxed::Box::new(TimestampView::default()))
227    }
228}
229unsafe impl<'a> ::buffa::HasDefaultViewInstance for TimestampView<'a> {
230    type Static = TimestampView<'static>;
231}