protobuf/well_known_types/
timestamp.rs1#![allow(unknown_lints)]
6#![allow(clippy::all)]
7
8#![allow(unused_attributes)]
9#![cfg_attr(rustfmt, rustfmt::skip)]
10
11#![allow(box_pointers)]
12#![allow(dead_code)]
13#![allow(missing_docs)]
14#![allow(non_camel_case_types)]
15#![allow(non_snake_case)]
16#![allow(non_upper_case_globals)]
17#![allow(trivial_casts)]
18#![allow(unused_imports)]
19#![allow(unused_results)]
20#[derive(PartialEq,Clone,Default)]
23#[cfg_attr(feature = "with-serde", derive(::serde::Serialize, ::serde::Deserialize))]
24pub struct Timestamp {
25 pub seconds: i64,
27 pub nanos: i32,
28 #[cfg_attr(feature = "with-serde", serde(skip))]
30 pub unknown_fields: crate::UnknownFields,
31 #[cfg_attr(feature = "with-serde", serde(skip))]
32 pub cached_size: crate::CachedSize,
33}
34
35impl<'a> ::std::default::Default for &'a Timestamp {
36 fn default() -> &'a Timestamp {
37 <Timestamp as crate::Message>::default_instance()
38 }
39}
40
41impl Timestamp {
42 pub fn new() -> Timestamp {
43 ::std::default::Default::default()
44 }
45
46 pub fn get_seconds(&self) -> i64 {
50 self.seconds
51 }
52 pub fn clear_seconds(&mut self) {
53 self.seconds = 0;
54 }
55
56 pub fn set_seconds(&mut self, v: i64) {
58 self.seconds = v;
59 }
60
61 pub fn get_nanos(&self) -> i32 {
65 self.nanos
66 }
67 pub fn clear_nanos(&mut self) {
68 self.nanos = 0;
69 }
70
71 pub fn set_nanos(&mut self, v: i32) {
73 self.nanos = v;
74 }
75}
76
77impl crate::Message for Timestamp {
78 fn is_initialized(&self) -> bool {
79 true
80 }
81
82 fn merge_from(&mut self, is: &mut crate::CodedInputStream<'_>) -> crate::ProtobufResult<()> {
83 while !is.eof()? {
84 let (field_number, wire_type) = is.read_tag_unpack()?;
85 match field_number {
86 1 => {
87 if wire_type != crate::wire_format::WireTypeVarint {
88 return ::std::result::Result::Err(crate::rt::unexpected_wire_type(wire_type));
89 }
90 let tmp = is.read_int64()?;
91 self.seconds = tmp;
92 },
93 2 => {
94 if wire_type != crate::wire_format::WireTypeVarint {
95 return ::std::result::Result::Err(crate::rt::unexpected_wire_type(wire_type));
96 }
97 let tmp = is.read_int32()?;
98 self.nanos = tmp;
99 },
100 _ => {
101 crate::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?;
102 },
103 };
104 }
105 ::std::result::Result::Ok(())
106 }
107
108 #[allow(unused_variables)]
110 fn compute_size(&self) -> u32 {
111 let mut my_size = 0;
112 if self.seconds != 0 {
113 my_size += crate::rt::value_size(1, self.seconds, crate::wire_format::WireTypeVarint);
114 }
115 if self.nanos != 0 {
116 my_size += crate::rt::value_size(2, self.nanos, crate::wire_format::WireTypeVarint);
117 }
118 my_size += crate::rt::unknown_fields_size(self.get_unknown_fields());
119 self.cached_size.set(my_size);
120 my_size
121 }
122
123 fn write_to_with_cached_sizes(&self, os: &mut crate::CodedOutputStream<'_>) -> crate::ProtobufResult<()> {
124 if self.seconds != 0 {
125 os.write_int64(1, self.seconds)?;
126 }
127 if self.nanos != 0 {
128 os.write_int32(2, self.nanos)?;
129 }
130 os.write_unknown_fields(self.get_unknown_fields())?;
131 ::std::result::Result::Ok(())
132 }
133
134 fn get_cached_size(&self) -> u32 {
135 self.cached_size.get()
136 }
137
138 fn get_unknown_fields(&self) -> &crate::UnknownFields {
139 &self.unknown_fields
140 }
141
142 fn mut_unknown_fields(&mut self) -> &mut crate::UnknownFields {
143 &mut self.unknown_fields
144 }
145
146 fn as_any(&self) -> &dyn (::std::any::Any) {
147 self as &dyn (::std::any::Any)
148 }
149 fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) {
150 self as &mut dyn (::std::any::Any)
151 }
152 fn into_any(self: ::std::boxed::Box<Self>) -> ::std::boxed::Box<dyn (::std::any::Any)> {
153 self
154 }
155
156 fn descriptor(&self) -> &'static crate::reflect::MessageDescriptor {
157 Self::descriptor_static()
158 }
159
160 fn new() -> Timestamp {
161 Timestamp::new()
162 }
163
164 fn descriptor_static() -> &'static crate::reflect::MessageDescriptor {
165 static descriptor: crate::rt::LazyV2<crate::reflect::MessageDescriptor> = crate::rt::LazyV2::INIT;
166 descriptor.get(|| {
167 let mut fields = ::std::vec::Vec::new();
168 fields.push(crate::reflect::accessor::make_simple_field_accessor::<_, crate::types::ProtobufTypeInt64>(
169 "seconds",
170 |m: &Timestamp| { &m.seconds },
171 |m: &mut Timestamp| { &mut m.seconds },
172 ));
173 fields.push(crate::reflect::accessor::make_simple_field_accessor::<_, crate::types::ProtobufTypeInt32>(
174 "nanos",
175 |m: &Timestamp| { &m.nanos },
176 |m: &mut Timestamp| { &mut m.nanos },
177 ));
178 crate::reflect::MessageDescriptor::new_pb_name::<Timestamp>(
179 "Timestamp",
180 fields,
181 file_descriptor_proto()
182 )
183 })
184 }
185
186 fn default_instance() -> &'static Timestamp {
187 static instance: crate::rt::LazyV2<Timestamp> = crate::rt::LazyV2::INIT;
188 instance.get(Timestamp::new)
189 }
190}
191
192impl crate::Clear for Timestamp {
193 fn clear(&mut self) {
194 self.seconds = 0;
195 self.nanos = 0;
196 self.unknown_fields.clear();
197 }
198}
199
200impl ::std::fmt::Debug for Timestamp {
201 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
202 crate::text_format::fmt(self, f)
203 }
204}
205
206impl crate::reflect::ProtobufValue for Timestamp {
207 fn as_ref(&self) -> crate::reflect::ReflectValueRef {
208 crate::reflect::ReflectValueRef::Message(self)
209 }
210}
211
212static file_descriptor_proto_data: &'static [u8] = b"\
213 \n\x1fgoogle/protobuf/timestamp.proto\x12\x0fgoogle.protobuf\";\n\tTimes\
214 tamp\x12\x18\n\x07seconds\x18\x01\x20\x01(\x03R\x07seconds\x12\x14\n\x05\
215 nanos\x18\x02\x20\x01(\x05R\x05nanosB\x85\x01\n\x13com.google.protobufB\
216 \x0eTimestampProtoP\x01Z2google.golang.org/protobuf/types/known/timestam\
217 ppb\xf8\x01\x01\xa2\x02\x03GPB\xaa\x02\x1eGoogle.Protobuf.WellKnownTypes\
218 J\xc5/\n\x07\x12\x05\x1e\0\x92\x01\x01\n\xcc\x0c\n\x01\x0c\x12\x03\x1e\0\
219 \x122\xc1\x0c\x20Protocol\x20Buffers\x20-\x20Google's\x20data\x20interch\
220 ange\x20format\n\x20Copyright\x202008\x20Google\x20Inc.\x20\x20All\x20ri\
221 ghts\x20reserved.\n\x20https://developers.google.com/protocol-buffers/\n\
222 \n\x20Redistribution\x20and\x20use\x20in\x20source\x20and\x20binary\x20f\
223 orms,\x20with\x20or\x20without\n\x20modification,\x20are\x20permitted\
224 \x20provided\x20that\x20the\x20following\x20conditions\x20are\n\x20met:\
225 \n\n\x20\x20\x20\x20\x20*\x20Redistributions\x20of\x20source\x20code\x20\
226 must\x20retain\x20the\x20above\x20copyright\n\x20notice,\x20this\x20list\
227 \x20of\x20conditions\x20and\x20the\x20following\x20disclaimer.\n\x20\x20\
228 \x20\x20\x20*\x20Redistributions\x20in\x20binary\x20form\x20must\x20repr\
229 oduce\x20the\x20above\n\x20copyright\x20notice,\x20this\x20list\x20of\
230 \x20conditions\x20and\x20the\x20following\x20disclaimer\n\x20in\x20the\
231 \x20documentation\x20and/or\x20other\x20materials\x20provided\x20with\
232 \x20the\n\x20distribution.\n\x20\x20\x20\x20\x20*\x20Neither\x20the\x20n\
233 ame\x20of\x20Google\x20Inc.\x20nor\x20the\x20names\x20of\x20its\n\x20con\
234 tributors\x20may\x20be\x20used\x20to\x20endorse\x20or\x20promote\x20prod\
235 ucts\x20derived\x20from\n\x20this\x20software\x20without\x20specific\x20\
236 prior\x20written\x20permission.\n\n\x20THIS\x20SOFTWARE\x20IS\x20PROVIDE\
237 D\x20BY\x20THE\x20COPYRIGHT\x20HOLDERS\x20AND\x20CONTRIBUTORS\n\x20\"AS\
238 \x20IS\"\x20AND\x20ANY\x20EXPRESS\x20OR\x20IMPLIED\x20WARRANTIES,\x20INC\
239 LUDING,\x20BUT\x20NOT\n\x20LIMITED\x20TO,\x20THE\x20IMPLIED\x20WARRANTIE\
240 S\x20OF\x20MERCHANTABILITY\x20AND\x20FITNESS\x20FOR\n\x20A\x20PARTICULAR\
241 \x20PURPOSE\x20ARE\x20DISCLAIMED.\x20IN\x20NO\x20EVENT\x20SHALL\x20THE\
242 \x20COPYRIGHT\n\x20OWNER\x20OR\x20CONTRIBUTORS\x20BE\x20LIABLE\x20FOR\
243 \x20ANY\x20DIRECT,\x20INDIRECT,\x20INCIDENTAL,\n\x20SPECIAL,\x20EXEMPLAR\
244 Y,\x20OR\x20CONSEQUENTIAL\x20DAMAGES\x20(INCLUDING,\x20BUT\x20NOT\n\x20L\
245 IMITED\x20TO,\x20PROCUREMENT\x20OF\x20SUBSTITUTE\x20GOODS\x20OR\x20SERVI\
246 CES;\x20LOSS\x20OF\x20USE,\n\x20DATA,\x20OR\x20PROFITS;\x20OR\x20BUSINES\
247 S\x20INTERRUPTION)\x20HOWEVER\x20CAUSED\x20AND\x20ON\x20ANY\n\x20THEORY\
248 \x20OF\x20LIABILITY,\x20WHETHER\x20IN\x20CONTRACT,\x20STRICT\x20LIABILIT\
249 Y,\x20OR\x20TORT\n\x20(INCLUDING\x20NEGLIGENCE\x20OR\x20OTHERWISE)\x20AR\
250 ISING\x20IN\x20ANY\x20WAY\x20OUT\x20OF\x20THE\x20USE\n\x20OF\x20THIS\x20\
251 SOFTWARE,\x20EVEN\x20IF\x20ADVISED\x20OF\x20THE\x20POSSIBILITY\x20OF\x20\
252 SUCH\x20DAMAGE.\n\n\x08\n\x01\x02\x12\x03\x20\0\x18\n\x08\n\x01\x08\x12\
253 \x03\"\0;\n\t\n\x02\x08%\x12\x03\"\0;\n\x08\n\x01\x08\x12\x03#\0\x1f\n\t\
254 \n\x02\x08\x1f\x12\x03#\0\x1f\n\x08\n\x01\x08\x12\x03$\0I\n\t\n\x02\x08\
255 \x0b\x12\x03$\0I\n\x08\n\x01\x08\x12\x03%\0,\n\t\n\x02\x08\x01\x12\x03%\
256 \0,\n\x08\n\x01\x08\x12\x03&\0/\n\t\n\x02\x08\x08\x12\x03&\0/\n\x08\n\
257 \x01\x08\x12\x03'\0\"\n\t\n\x02\x08\n\x12\x03'\0\"\n\x08\n\x01\x08\x12\
258 \x03(\0!\n\t\n\x02\x08$\x12\x03(\0!\n\xde\x1d\n\x02\x04\0\x12\x06\x87\
259 \x01\0\x92\x01\x01\x1a\xcf\x1d\x20A\x20Timestamp\x20represents\x20a\x20p\
260 oint\x20in\x20time\x20independent\x20of\x20any\x20time\x20zone\x20or\x20\
261 local\n\x20calendar,\x20encoded\x20as\x20a\x20count\x20of\x20seconds\x20\
262 and\x20fractions\x20of\x20seconds\x20at\n\x20nanosecond\x20resolution.\
263 \x20The\x20count\x20is\x20relative\x20to\x20an\x20epoch\x20at\x20UTC\x20\
264 midnight\x20on\n\x20January\x201,\x201970,\x20in\x20the\x20proleptic\x20\
265 Gregorian\x20calendar\x20which\x20extends\x20the\n\x20Gregorian\x20calen\
266 dar\x20backwards\x20to\x20year\x20one.\n\n\x20All\x20minutes\x20are\x206\
267 0\x20seconds\x20long.\x20Leap\x20seconds\x20are\x20\"smeared\"\x20so\x20\
268 that\x20no\x20leap\n\x20second\x20table\x20is\x20needed\x20for\x20interp\
269 retation,\x20using\x20a\x20[24-hour\x20linear\n\x20smear](https://develo\
270 pers.google.com/time/smear).\n\n\x20The\x20range\x20is\x20from\x200001-0\
271 1-01T00:00:00Z\x20to\x209999-12-31T23:59:59.999999999Z.\x20By\n\x20restr\
272 icting\x20to\x20that\x20range,\x20we\x20ensure\x20that\x20we\x20can\x20c\
273 onvert\x20to\x20and\x20from\x20[RFC\n\x203339](https://www.ietf.org/rfc/\
274 rfc3339.txt)\x20date\x20strings.\n\n\x20#\x20Examples\n\n\x20Example\x20\
275 1:\x20Compute\x20Timestamp\x20from\x20POSIX\x20`time()`.\n\n\x20\x20\x20\
276 \x20\x20Timestamp\x20timestamp;\n\x20\x20\x20\x20\x20timestamp.set_secon\
277 ds(time(NULL));\n\x20\x20\x20\x20\x20timestamp.set_nanos(0);\n\n\x20Exam\
278 ple\x202:\x20Compute\x20Timestamp\x20from\x20POSIX\x20`gettimeofday()`.\
279 \n\n\x20\x20\x20\x20\x20struct\x20timeval\x20tv;\n\x20\x20\x20\x20\x20ge\
280 ttimeofday(&tv,\x20NULL);\n\n\x20\x20\x20\x20\x20Timestamp\x20timestamp;\
281 \n\x20\x20\x20\x20\x20timestamp.set_seconds(tv.tv_sec);\n\x20\x20\x20\
282 \x20\x20timestamp.set_nanos(tv.tv_usec\x20*\x201000);\n\n\x20Example\x20\
283 3:\x20Compute\x20Timestamp\x20from\x20Win32\x20`GetSystemTimeAsFileTime(\
284 )`.\n\n\x20\x20\x20\x20\x20FILETIME\x20ft;\n\x20\x20\x20\x20\x20GetSyste\
285 mTimeAsFileTime(&ft);\n\x20\x20\x20\x20\x20UINT64\x20ticks\x20=\x20(((UI\
286 NT64)ft.dwHighDateTime)\x20<<\x2032)\x20|\x20ft.dwLowDateTime;\n\n\x20\
287 \x20\x20\x20\x20//\x20A\x20Windows\x20tick\x20is\x20100\x20nanoseconds.\
288 \x20Windows\x20epoch\x201601-01-01T00:00:00Z\n\x20\x20\x20\x20\x20//\x20\
289 is\x2011644473600\x20seconds\x20before\x20Unix\x20epoch\x201970-01-01T00\
290 :00:00Z.\n\x20\x20\x20\x20\x20Timestamp\x20timestamp;\n\x20\x20\x20\x20\
291 \x20timestamp.set_seconds((INT64)\x20((ticks\x20/\x2010000000)\x20-\x201\
292 1644473600LL));\n\x20\x20\x20\x20\x20timestamp.set_nanos((INT32)\x20((ti\
293 cks\x20%\x2010000000)\x20*\x20100));\n\n\x20Example\x204:\x20Compute\x20\
294 Timestamp\x20from\x20Java\x20`System.currentTimeMillis()`.\n\n\x20\x20\
295 \x20\x20\x20long\x20millis\x20=\x20System.currentTimeMillis();\n\n\x20\
296 \x20\x20\x20\x20Timestamp\x20timestamp\x20=\x20Timestamp.newBuilder().se\
297 tSeconds(millis\x20/\x201000)\n\x20\x20\x20\x20\x20\x20\x20\x20\x20.setN\
298 anos((int)\x20((millis\x20%\x201000)\x20*\x201000000)).build();\n\n\n\
299 \x20Example\x205:\x20Compute\x20Timestamp\x20from\x20Java\x20`Instant.no\
300 w()`.\n\n\x20\x20\x20\x20\x20Instant\x20now\x20=\x20Instant.now();\n\n\
301 \x20\x20\x20\x20\x20Timestamp\x20timestamp\x20=\n\x20\x20\x20\x20\x20\
302 \x20\x20\x20\x20Timestamp.newBuilder().setSeconds(now.getEpochSecond())\
303 \n\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20.setNanos(now.getN\
304 ano()).build();\n\n\n\x20Example\x206:\x20Compute\x20Timestamp\x20from\
305 \x20current\x20time\x20in\x20Python.\n\n\x20\x20\x20\x20\x20timestamp\
306 \x20=\x20Timestamp()\n\x20\x20\x20\x20\x20timestamp.GetCurrentTime()\n\n\
307 \x20#\x20JSON\x20Mapping\n\n\x20In\x20JSON\x20format,\x20the\x20Timestam\
308 p\x20type\x20is\x20encoded\x20as\x20a\x20string\x20in\x20the\n\x20[RFC\
309 \x203339](https://www.ietf.org/rfc/rfc3339.txt)\x20format.\x20That\x20is\
310 ,\x20the\n\x20format\x20is\x20\"{year}-{month}-{day}T{hour}:{min}:{sec}[\
311 .{frac_sec}]Z\"\n\x20where\x20{year}\x20is\x20always\x20expressed\x20usi\
312 ng\x20four\x20digits\x20while\x20{month},\x20{day},\n\x20{hour},\x20{min\
313 },\x20and\x20{sec}\x20are\x20zero-padded\x20to\x20two\x20digits\x20each.\
314 \x20The\x20fractional\n\x20seconds,\x20which\x20can\x20go\x20up\x20to\
315 \x209\x20digits\x20(i.e.\x20up\x20to\x201\x20nanosecond\x20resolution),\
316 \n\x20are\x20optional.\x20The\x20\"Z\"\x20suffix\x20indicates\x20the\x20\
317 timezone\x20(\"UTC\");\x20the\x20timezone\n\x20is\x20required.\x20A\x20p\
318 roto3\x20JSON\x20serializer\x20should\x20always\x20use\x20UTC\x20(as\x20\
319 indicated\x20by\n\x20\"Z\")\x20when\x20printing\x20the\x20Timestamp\x20t\
320 ype\x20and\x20a\x20proto3\x20JSON\x20parser\x20should\x20be\n\x20able\
321 \x20to\x20accept\x20both\x20UTC\x20and\x20other\x20timezones\x20(as\x20i\
322 ndicated\x20by\x20an\x20offset).\n\n\x20For\x20example,\x20\"2017-01-15T\
323 01:30:15.01Z\"\x20encodes\x2015.01\x20seconds\x20past\n\x2001:30\x20UTC\
324 \x20on\x20January\x2015,\x202017.\n\n\x20In\x20JavaScript,\x20one\x20can\
325 \x20convert\x20a\x20Date\x20object\x20to\x20this\x20format\x20using\x20t\
326 he\n\x20standard\n\x20[toISOString()](https://developer.mozilla.org/en-U\
327 S/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)\n\x20me\
328 thod.\x20In\x20Python,\x20a\x20standard\x20`datetime.datetime`\x20object\
329 \x20can\x20be\x20converted\n\x20to\x20this\x20format\x20using\n\x20[`str\
330 ftime`](https://docs.python.org/2/library/time.html#time.strftime)\x20wi\
331 th\n\x20the\x20time\x20format\x20spec\x20'%Y-%m-%dT%H:%M:%S.%fZ'.\x20Lik\
332 ewise,\x20in\x20Java,\x20one\x20can\x20use\n\x20the\x20Joda\x20Time's\
333 \x20[`ISODateTimeFormat.dateTime()`](\n\x20http://www.joda.org/joda-time\
334 /apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D\n\
335 \x20)\x20to\x20obtain\x20a\x20formatter\x20capable\x20of\x20generating\
336 \x20timestamps\x20in\x20this\x20format.\n\n\n\n\x0b\n\x03\x04\0\x01\x12\
337 \x04\x87\x01\x08\x11\n\x9d\x01\n\x04\x04\0\x02\0\x12\x04\x8b\x01\x02\x14\
338 \x1a\x8e\x01\x20Represents\x20seconds\x20of\x20UTC\x20time\x20since\x20U\
339 nix\x20epoch\n\x201970-01-01T00:00:00Z.\x20Must\x20be\x20from\x200001-01\
340 -01T00:00:00Z\x20to\n\x209999-12-31T23:59:59Z\x20inclusive.\n\n\r\n\x05\
341 \x04\0\x02\0\x05\x12\x04\x8b\x01\x02\x07\n\r\n\x05\x04\0\x02\0\x01\x12\
342 \x04\x8b\x01\x08\x0f\n\r\n\x05\x04\0\x02\0\x03\x12\x04\x8b\x01\x12\x13\n\
343 \xe5\x01\n\x04\x04\0\x02\x01\x12\x04\x91\x01\x02\x12\x1a\xd6\x01\x20Non-\
344 negative\x20fractions\x20of\x20a\x20second\x20at\x20nanosecond\x20resolu\
345 tion.\x20Negative\n\x20second\x20values\x20with\x20fractions\x20must\x20\
346 still\x20have\x20non-negative\x20nanos\x20values\n\x20that\x20count\x20f\
347 orward\x20in\x20time.\x20Must\x20be\x20from\x200\x20to\x20999,999,999\n\
348 \x20inclusive.\n\n\r\n\x05\x04\0\x02\x01\x05\x12\x04\x91\x01\x02\x07\n\r\
349 \n\x05\x04\0\x02\x01\x01\x12\x04\x91\x01\x08\r\n\r\n\x05\x04\0\x02\x01\
350 \x03\x12\x04\x91\x01\x10\x11b\x06proto3\
351";
352
353static file_descriptor_proto_lazy: crate::rt::LazyV2<crate::descriptor::FileDescriptorProto> = crate::rt::LazyV2::INIT;
354
355fn parse_descriptor_proto() -> crate::descriptor::FileDescriptorProto {
356 crate::Message::parse_from_bytes(file_descriptor_proto_data).unwrap()
357}
358
359pub fn file_descriptor_proto() -> &'static crate::descriptor::FileDescriptorProto {
360 file_descriptor_proto_lazy.get(|| {
361 parse_descriptor_proto()
362 })
363}