protobuf/well_known_types/
duration.rs

1// This file is generated by rust-protobuf 4.0.0-alpha.0. Do not edit
2// .proto file is parsed by protoc --rs_out=...
3// @generated
4
5// https://github.com/rust-lang/rust-clippy/issues/702
6#![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//! Generated file from `google/protobuf/duration.proto`
22
23// @@protoc_insertion_point(message:google.protobuf.Duration)
24#[derive(PartialEq,Clone,Default,Debug)]
25pub struct Duration {
26    // message fields
27    ///  Signed seconds of the span of time. Must be from -315,576,000,000
28    ///  to +315,576,000,000 inclusive. Note: these bounds are computed from:
29    ///  60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
30    // @@protoc_insertion_point(field:google.protobuf.Duration.seconds)
31    pub seconds: i64,
32    ///  Signed fractions of a second at nanosecond resolution of the span
33    ///  of time. Durations less than one second are represented with a 0
34    ///  `seconds` field and a positive or negative `nanos` field. For durations
35    ///  of one second or more, a non-zero value for the `nanos` field must be
36    ///  of the same sign as the `seconds` field. Must be from -999,999,999
37    ///  to +999,999,999 inclusive.
38    // @@protoc_insertion_point(field:google.protobuf.Duration.nanos)
39    pub nanos: i32,
40    // special fields
41    // @@protoc_insertion_point(special_field:google.protobuf.Duration.special_fields)
42    pub special_fields: crate::SpecialFields,
43}
44
45impl<'a> ::std::default::Default for &'a Duration {
46    fn default() -> &'a Duration {
47        <Duration as crate::Message>::default_instance()
48    }
49}
50
51impl Duration {
52    pub fn new() -> Duration {
53        ::std::default::Default::default()
54    }
55
56    fn generated_message_descriptor_data() -> crate::reflect::GeneratedMessageDescriptorData {
57        let mut fields = ::std::vec::Vec::with_capacity(2);
58        let mut oneofs = ::std::vec::Vec::with_capacity(0);
59        fields.push(crate::reflect::rt::v2::make_simpler_field_accessor::<_, _>(
60            "seconds",
61            |m: &Duration| { &m.seconds },
62            |m: &mut Duration| { &mut m.seconds },
63        ));
64        fields.push(crate::reflect::rt::v2::make_simpler_field_accessor::<_, _>(
65            "nanos",
66            |m: &Duration| { &m.nanos },
67            |m: &mut Duration| { &mut m.nanos },
68        ));
69        crate::reflect::GeneratedMessageDescriptorData::new_2::<Duration>(
70            "Duration",
71            fields,
72            oneofs,
73        )
74    }
75}
76
77impl crate::Message for Duration {
78    const NAME: &'static str = "Duration";
79
80    fn is_initialized(&self) -> bool {
81        true
82    }
83
84    fn merge_from(&mut self, is: &mut crate::CodedInputStream<'_>) -> crate::Result<()> {
85        while let Some(tag) = is.read_raw_tag_or_eof()? {
86            match tag {
87                8 => {
88                    self.seconds = is.read_int64()?;
89                },
90                16 => {
91                    self.nanos = is.read_int32()?;
92                },
93                tag => {
94                    crate::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?;
95                },
96            };
97        }
98        ::std::result::Result::Ok(())
99    }
100
101    // Compute sizes of nested messages
102    #[allow(unused_variables)]
103    fn compute_size(&self) -> u64 {
104        let mut my_size = 0;
105        if self.seconds != 0 {
106            my_size += crate::rt::int64_size(1, self.seconds);
107        }
108        if self.nanos != 0 {
109            my_size += crate::rt::int32_size(2, self.nanos);
110        }
111        my_size += crate::rt::unknown_fields_size(self.special_fields.unknown_fields());
112        self.special_fields.cached_size().set(my_size as u32);
113        my_size
114    }
115
116    fn write_to_with_cached_sizes(&self, os: &mut crate::CodedOutputStream<'_>) -> crate::Result<()> {
117        if self.seconds != 0 {
118            os.write_int64(1, self.seconds)?;
119        }
120        if self.nanos != 0 {
121            os.write_int32(2, self.nanos)?;
122        }
123        os.write_unknown_fields(self.special_fields.unknown_fields())?;
124        ::std::result::Result::Ok(())
125    }
126
127    fn special_fields(&self) -> &crate::SpecialFields {
128        &self.special_fields
129    }
130
131    fn mut_special_fields(&mut self) -> &mut crate::SpecialFields {
132        &mut self.special_fields
133    }
134
135    fn new() -> Duration {
136        Duration::new()
137    }
138
139    fn clear(&mut self) {
140        self.seconds = 0;
141        self.nanos = 0;
142        self.special_fields.clear();
143    }
144
145    fn default_instance() -> &'static Duration {
146        static instance: Duration = Duration {
147            seconds: 0,
148            nanos: 0,
149            special_fields: crate::SpecialFields::new(),
150        };
151        &instance
152    }
153}
154
155impl crate::MessageFull for Duration {
156    fn descriptor() -> crate::reflect::MessageDescriptor {
157        static descriptor: crate::rt::Lazy<crate::reflect::MessageDescriptor> = crate::rt::Lazy::new();
158        descriptor.get(|| file_descriptor().message_by_package_relative_name("Duration").unwrap()).clone()
159    }
160}
161
162impl ::std::fmt::Display for Duration {
163    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
164        crate::text_format::fmt(self, f)
165    }
166}
167
168impl crate::reflect::ProtobufValue for Duration {
169    type RuntimeType = crate::reflect::rt::RuntimeTypeMessage<Self>;
170}
171
172static file_descriptor_proto_data: &'static [u8] = b"\
173    \n\x1egoogle/protobuf/duration.proto\x12\x0fgoogle.protobuf\":\n\x08Dura\
174    tion\x12\x18\n\x07seconds\x18\x01\x20\x01(\x03R\x07seconds\x12\x14\n\x05\
175    nanos\x18\x02\x20\x01(\x05R\x05nanosB\x83\x01\n\x13com.google.protobufB\
176    \rDurationProtoP\x01Z1google.golang.org/protobuf/types/known/durationpb\
177    \xf8\x01\x01\xa2\x02\x03GPB\xaa\x02\x1eGoogle.Protobuf.WellKnownTypesJ\
178    \xda#\n\x06\x12\x04\x1e\0s\x01\n\xcc\x0c\n\x01\x0c\x12\x03\x1e\0\x122\
179    \xc1\x0c\x20Protocol\x20Buffers\x20-\x20Google's\x20data\x20interchange\
180    \x20format\n\x20Copyright\x202008\x20Google\x20Inc.\x20\x20All\x20rights\
181    \x20reserved.\n\x20https://developers.google.com/protocol-buffers/\n\n\
182    \x20Redistribution\x20and\x20use\x20in\x20source\x20and\x20binary\x20for\
183    ms,\x20with\x20or\x20without\n\x20modification,\x20are\x20permitted\x20p\
184    rovided\x20that\x20the\x20following\x20conditions\x20are\n\x20met:\n\n\
185    \x20\x20\x20\x20\x20*\x20Redistributions\x20of\x20source\x20code\x20must\
186    \x20retain\x20the\x20above\x20copyright\n\x20notice,\x20this\x20list\x20\
187    of\x20conditions\x20and\x20the\x20following\x20disclaimer.\n\x20\x20\x20\
188    \x20\x20*\x20Redistributions\x20in\x20binary\x20form\x20must\x20reproduc\
189    e\x20the\x20above\n\x20copyright\x20notice,\x20this\x20list\x20of\x20con\
190    ditions\x20and\x20the\x20following\x20disclaimer\n\x20in\x20the\x20docum\
191    entation\x20and/or\x20other\x20materials\x20provided\x20with\x20the\n\
192    \x20distribution.\n\x20\x20\x20\x20\x20*\x20Neither\x20the\x20name\x20of\
193    \x20Google\x20Inc.\x20nor\x20the\x20names\x20of\x20its\n\x20contributors\
194    \x20may\x20be\x20used\x20to\x20endorse\x20or\x20promote\x20products\x20d\
195    erived\x20from\n\x20this\x20software\x20without\x20specific\x20prior\x20\
196    written\x20permission.\n\n\x20THIS\x20SOFTWARE\x20IS\x20PROVIDED\x20BY\
197    \x20THE\x20COPYRIGHT\x20HOLDERS\x20AND\x20CONTRIBUTORS\n\x20\"AS\x20IS\"\
198    \x20AND\x20ANY\x20EXPRESS\x20OR\x20IMPLIED\x20WARRANTIES,\x20INCLUDING,\
199    \x20BUT\x20NOT\n\x20LIMITED\x20TO,\x20THE\x20IMPLIED\x20WARRANTIES\x20OF\
200    \x20MERCHANTABILITY\x20AND\x20FITNESS\x20FOR\n\x20A\x20PARTICULAR\x20PUR\
201    POSE\x20ARE\x20DISCLAIMED.\x20IN\x20NO\x20EVENT\x20SHALL\x20THE\x20COPYR\
202    IGHT\n\x20OWNER\x20OR\x20CONTRIBUTORS\x20BE\x20LIABLE\x20FOR\x20ANY\x20D\
203    IRECT,\x20INDIRECT,\x20INCIDENTAL,\n\x20SPECIAL,\x20EXEMPLARY,\x20OR\x20\
204    CONSEQUENTIAL\x20DAMAGES\x20(INCLUDING,\x20BUT\x20NOT\n\x20LIMITED\x20TO\
205    ,\x20PROCUREMENT\x20OF\x20SUBSTITUTE\x20GOODS\x20OR\x20SERVICES;\x20LOSS\
206    \x20OF\x20USE,\n\x20DATA,\x20OR\x20PROFITS;\x20OR\x20BUSINESS\x20INTERRU\
207    PTION)\x20HOWEVER\x20CAUSED\x20AND\x20ON\x20ANY\n\x20THEORY\x20OF\x20LIA\
208    BILITY,\x20WHETHER\x20IN\x20CONTRACT,\x20STRICT\x20LIABILITY,\x20OR\x20T\
209    ORT\n\x20(INCLUDING\x20NEGLIGENCE\x20OR\x20OTHERWISE)\x20ARISING\x20IN\
210    \x20ANY\x20WAY\x20OUT\x20OF\x20THE\x20USE\n\x20OF\x20THIS\x20SOFTWARE,\
211    \x20EVEN\x20IF\x20ADVISED\x20OF\x20THE\x20POSSIBILITY\x20OF\x20SUCH\x20D\
212    AMAGE.\n\n\x08\n\x01\x02\x12\x03\x20\0\x18\n\x08\n\x01\x08\x12\x03\"\0;\
213    \n\t\n\x02\x08%\x12\x03\"\0;\n\x08\n\x01\x08\x12\x03#\0\x1f\n\t\n\x02\
214    \x08\x1f\x12\x03#\0\x1f\n\x08\n\x01\x08\x12\x03$\0H\n\t\n\x02\x08\x0b\
215    \x12\x03$\0H\n\x08\n\x01\x08\x12\x03%\0,\n\t\n\x02\x08\x01\x12\x03%\0,\n\
216    \x08\n\x01\x08\x12\x03&\0.\n\t\n\x02\x08\x08\x12\x03&\0.\n\x08\n\x01\x08\
217    \x12\x03'\0\"\n\t\n\x02\x08\n\x12\x03'\0\"\n\x08\n\x01\x08\x12\x03(\0!\n\
218    \t\n\x02\x08$\x12\x03(\0!\n\x9e\x10\n\x02\x04\0\x12\x04f\0s\x01\x1a\x91\
219    \x10\x20A\x20Duration\x20represents\x20a\x20signed,\x20fixed-length\x20s\
220    pan\x20of\x20time\x20represented\n\x20as\x20a\x20count\x20of\x20seconds\
221    \x20and\x20fractions\x20of\x20seconds\x20at\x20nanosecond\n\x20resolutio\
222    n.\x20It\x20is\x20independent\x20of\x20any\x20calendar\x20and\x20concept\
223    s\x20like\x20\"day\"\n\x20or\x20\"month\".\x20It\x20is\x20related\x20to\
224    \x20Timestamp\x20in\x20that\x20the\x20difference\x20between\n\x20two\x20\
225    Timestamp\x20values\x20is\x20a\x20Duration\x20and\x20it\x20can\x20be\x20\
226    added\x20or\x20subtracted\n\x20from\x20a\x20Timestamp.\x20Range\x20is\
227    \x20approximately\x20+-10,000\x20years.\n\n\x20#\x20Examples\n\n\x20Exam\
228    ple\x201:\x20Compute\x20Duration\x20from\x20two\x20Timestamps\x20in\x20p\
229    seudo\x20code.\n\n\x20\x20\x20\x20\x20Timestamp\x20start\x20=\x20...;\n\
230    \x20\x20\x20\x20\x20Timestamp\x20end\x20=\x20...;\n\x20\x20\x20\x20\x20D\
231    uration\x20duration\x20=\x20...;\n\n\x20\x20\x20\x20\x20duration.seconds\
232    \x20=\x20end.seconds\x20-\x20start.seconds;\n\x20\x20\x20\x20\x20duratio\
233    n.nanos\x20=\x20end.nanos\x20-\x20start.nanos;\n\n\x20\x20\x20\x20\x20if\
234    \x20(duration.seconds\x20<\x200\x20&&\x20duration.nanos\x20>\x200)\x20{\
235    \n\x20\x20\x20\x20\x20\x20\x20duration.seconds\x20+=\x201;\n\x20\x20\x20\
236    \x20\x20\x20\x20duration.nanos\x20-=\x201000000000;\n\x20\x20\x20\x20\
237    \x20}\x20else\x20if\x20(duration.seconds\x20>\x200\x20&&\x20duration.nan\
238    os\x20<\x200)\x20{\n\x20\x20\x20\x20\x20\x20\x20duration.seconds\x20-=\
239    \x201;\n\x20\x20\x20\x20\x20\x20\x20duration.nanos\x20+=\x201000000000;\
240    \n\x20\x20\x20\x20\x20}\n\n\x20Example\x202:\x20Compute\x20Timestamp\x20\
241    from\x20Timestamp\x20+\x20Duration\x20in\x20pseudo\x20code.\n\n\x20\x20\
242    \x20\x20\x20Timestamp\x20start\x20=\x20...;\n\x20\x20\x20\x20\x20Duratio\
243    n\x20duration\x20=\x20...;\n\x20\x20\x20\x20\x20Timestamp\x20end\x20=\
244    \x20...;\n\n\x20\x20\x20\x20\x20end.seconds\x20=\x20start.seconds\x20+\
245    \x20duration.seconds;\n\x20\x20\x20\x20\x20end.nanos\x20=\x20start.nanos\
246    \x20+\x20duration.nanos;\n\n\x20\x20\x20\x20\x20if\x20(end.nanos\x20<\
247    \x200)\x20{\n\x20\x20\x20\x20\x20\x20\x20end.seconds\x20-=\x201;\n\x20\
248    \x20\x20\x20\x20\x20\x20end.nanos\x20+=\x201000000000;\n\x20\x20\x20\x20\
249    \x20}\x20else\x20if\x20(end.nanos\x20>=\x201000000000)\x20{\n\x20\x20\
250    \x20\x20\x20\x20\x20end.seconds\x20+=\x201;\n\x20\x20\x20\x20\x20\x20\
251    \x20end.nanos\x20-=\x201000000000;\n\x20\x20\x20\x20\x20}\n\n\x20Example\
252    \x203:\x20Compute\x20Duration\x20from\x20datetime.timedelta\x20in\x20Pyt\
253    hon.\n\n\x20\x20\x20\x20\x20td\x20=\x20datetime.timedelta(days=3,\x20min\
254    utes=10)\n\x20\x20\x20\x20\x20duration\x20=\x20Duration()\n\x20\x20\x20\
255    \x20\x20duration.FromTimedelta(td)\n\n\x20#\x20JSON\x20Mapping\n\n\x20In\
256    \x20JSON\x20format,\x20the\x20Duration\x20type\x20is\x20encoded\x20as\
257    \x20a\x20string\x20rather\x20than\x20an\n\x20object,\x20where\x20the\x20\
258    string\x20ends\x20in\x20the\x20suffix\x20\"s\"\x20(indicating\x20seconds\
259    )\x20and\n\x20is\x20preceded\x20by\x20the\x20number\x20of\x20seconds,\
260    \x20with\x20nanoseconds\x20expressed\x20as\n\x20fractional\x20seconds.\
261    \x20For\x20example,\x203\x20seconds\x20with\x200\x20nanoseconds\x20shoul\
262    d\x20be\n\x20encoded\x20in\x20JSON\x20format\x20as\x20\"3s\",\x20while\
263    \x203\x20seconds\x20and\x201\x20nanosecond\x20should\n\x20be\x20expresse\
264    d\x20in\x20JSON\x20format\x20as\x20\"3.000000001s\",\x20and\x203\x20seco\
265    nds\x20and\x201\n\x20microsecond\x20should\x20be\x20expressed\x20in\x20J\
266    SON\x20format\x20as\x20\"3.000001s\".\n\n\n\n\n\n\x03\x04\0\x01\x12\x03f\
267    \x08\x10\n\xdc\x01\n\x04\x04\0\x02\0\x12\x03j\x02\x14\x1a\xce\x01\x20Sig\
268    ned\x20seconds\x20of\x20the\x20span\x20of\x20time.\x20Must\x20be\x20from\
269    \x20-315,576,000,000\n\x20to\x20+315,576,000,000\x20inclusive.\x20Note:\
270    \x20these\x20bounds\x20are\x20computed\x20from:\n\x2060\x20sec/min\x20*\
271    \x2060\x20min/hr\x20*\x2024\x20hr/day\x20*\x20365.25\x20days/year\x20*\
272    \x2010000\x20years\n\n\x0c\n\x05\x04\0\x02\0\x05\x12\x03j\x02\x07\n\x0c\
273    \n\x05\x04\0\x02\0\x01\x12\x03j\x08\x0f\n\x0c\n\x05\x04\0\x02\0\x03\x12\
274    \x03j\x12\x13\n\x83\x03\n\x04\x04\0\x02\x01\x12\x03r\x02\x12\x1a\xf5\x02\
275    \x20Signed\x20fractions\x20of\x20a\x20second\x20at\x20nanosecond\x20reso\
276    lution\x20of\x20the\x20span\n\x20of\x20time.\x20Durations\x20less\x20tha\
277    n\x20one\x20second\x20are\x20represented\x20with\x20a\x200\n\x20`seconds\
278    `\x20field\x20and\x20a\x20positive\x20or\x20negative\x20`nanos`\x20field\
279    .\x20For\x20durations\n\x20of\x20one\x20second\x20or\x20more,\x20a\x20no\
280    n-zero\x20value\x20for\x20the\x20`nanos`\x20field\x20must\x20be\n\x20of\
281    \x20the\x20same\x20sign\x20as\x20the\x20`seconds`\x20field.\x20Must\x20b\
282    e\x20from\x20-999,999,999\n\x20to\x20+999,999,999\x20inclusive.\n\n\x0c\
283    \n\x05\x04\0\x02\x01\x05\x12\x03r\x02\x07\n\x0c\n\x05\x04\0\x02\x01\x01\
284    \x12\x03r\x08\r\n\x0c\n\x05\x04\0\x02\x01\x03\x12\x03r\x10\x11b\x06proto\
285    3\
286";
287
288/// `FileDescriptorProto` object which was a source for this generated file
289fn file_descriptor_proto() -> &'static crate::descriptor::FileDescriptorProto {
290    static file_descriptor_proto_lazy: crate::rt::Lazy<crate::descriptor::FileDescriptorProto> = crate::rt::Lazy::new();
291    file_descriptor_proto_lazy.get(|| {
292        crate::Message::parse_from_bytes(file_descriptor_proto_data).unwrap()
293    })
294}
295
296/// `FileDescriptor` object which allows dynamic access to files
297pub fn file_descriptor() -> &'static crate::reflect::FileDescriptor {
298    static generated_file_descriptor_lazy: crate::rt::Lazy<crate::reflect::GeneratedFileDescriptor> = crate::rt::Lazy::new();
299    static file_descriptor: crate::rt::Lazy<crate::reflect::FileDescriptor> = crate::rt::Lazy::new();
300    file_descriptor.get(|| {
301        let generated_file_descriptor = generated_file_descriptor_lazy.get(|| {
302            let mut deps = ::std::vec::Vec::with_capacity(0);
303            let mut messages = ::std::vec::Vec::with_capacity(1);
304            messages.push(Duration::generated_message_descriptor_data());
305            let mut enums = ::std::vec::Vec::with_capacity(0);
306            crate::reflect::GeneratedFileDescriptor::new_generated(
307                file_descriptor_proto(),
308                deps,
309                messages,
310                enums,
311            )
312        });
313        crate::reflect::FileDescriptor::new_generated_2(generated_file_descriptor)
314    })
315}