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