1// Code generated by protoc-gen-gogo. DO NOT EDIT.
2// source: google/protobuf/duration.proto
3
4package types
5
6import proto "github.com/gogo/protobuf/proto"
7import fmt "fmt"
8import math "math"
9
10import bytes "bytes"
11
12import strings "strings"
13import reflect "reflect"
14
15import io "io"
16
17// Reference imports to suppress errors if they are not otherwise used.
18var _ = proto.Marshal
19var _ = fmt.Errorf
20var _ = math.Inf
21
22// This is a compile-time assertion to ensure that this generated file
23// is compatible with the proto package it is being compiled against.
24// A compilation error at this line likely means your copy of the
25// proto package needs to be updated.
26const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
27
28// A Duration represents a signed, fixed-length span of time represented
29// as a count of seconds and fractions of seconds at nanosecond
30// resolution. It is independent of any calendar and concepts like "day"
31// or "month". It is related to Timestamp in that the difference between
32// two Timestamp values is a Duration and it can be added or subtracted
33// from a Timestamp. Range is approximately +-10,000 years.
34//
35// # Examples
36//
37// Example 1: Compute Duration from two Timestamps in pseudo code.
38//
39//     Timestamp start = ...;
40//     Timestamp end = ...;
41//     Duration duration = ...;
42//
43//     duration.seconds = end.seconds - start.seconds;
44//     duration.nanos = end.nanos - start.nanos;
45//
46//     if (duration.seconds < 0 && duration.nanos > 0) {
47//       duration.seconds += 1;
48//       duration.nanos -= 1000000000;
49//     } else if (durations.seconds > 0 && duration.nanos < 0) {
50//       duration.seconds -= 1;
51//       duration.nanos += 1000000000;
52//     }
53//
54// Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
55//
56//     Timestamp start = ...;
57//     Duration duration = ...;
58//     Timestamp end = ...;
59//
60//     end.seconds = start.seconds + duration.seconds;
61//     end.nanos = start.nanos + duration.nanos;
62//
63//     if (end.nanos < 0) {
64//       end.seconds -= 1;
65//       end.nanos += 1000000000;
66//     } else if (end.nanos >= 1000000000) {
67//       end.seconds += 1;
68//       end.nanos -= 1000000000;
69//     }
70//
71// Example 3: Compute Duration from datetime.timedelta in Python.
72//
73//     td = datetime.timedelta(days=3, minutes=10)
74//     duration = Duration()
75//     duration.FromTimedelta(td)
76//
77// # JSON Mapping
78//
79// In JSON format, the Duration type is encoded as a string rather than an
80// object, where the string ends in the suffix "s" (indicating seconds) and
81// is preceded by the number of seconds, with nanoseconds expressed as
82// fractional seconds. For example, 3 seconds with 0 nanoseconds should be
83// encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
84// be expressed in JSON format as "3.000000001s", and 3 seconds and 1
85// microsecond should be expressed in JSON format as "3.000001s".
86//
87//
88type Duration struct {
89	// Signed seconds of the span of time. Must be from -315,576,000,000
90	// to +315,576,000,000 inclusive. Note: these bounds are computed from:
91	// 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
92	Seconds int64 `protobuf:"varint,1,opt,name=seconds,proto3" json:"seconds,omitempty"`
93	// Signed fractions of a second at nanosecond resolution of the span
94	// of time. Durations less than one second are represented with a 0
95	// `seconds` field and a positive or negative `nanos` field. For durations
96	// of one second or more, a non-zero value for the `nanos` field must be
97	// of the same sign as the `seconds` field. Must be from -999,999,999
98	// to +999,999,999 inclusive.
99	Nanos                int32    `protobuf:"varint,2,opt,name=nanos,proto3" json:"nanos,omitempty"`
100	XXX_NoUnkeyedLiteral struct{} `json:"-"`
101	XXX_unrecognized     []byte   `json:"-"`
102	XXX_sizecache        int32    `json:"-"`
103}
104
105func (m *Duration) Reset()      { *m = Duration{} }
106func (*Duration) ProtoMessage() {}
107func (*Duration) Descriptor() ([]byte, []int) {
108	return fileDescriptor_duration_7f04bf66a647e6f6, []int{0}
109}
110func (*Duration) XXX_WellKnownType() string { return "Duration" }
111func (m *Duration) XXX_Unmarshal(b []byte) error {
112	return m.Unmarshal(b)
113}
114func (m *Duration) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
115	if deterministic {
116		return xxx_messageInfo_Duration.Marshal(b, m, deterministic)
117	} else {
118		b = b[:cap(b)]
119		n, err := m.MarshalTo(b)
120		if err != nil {
121			return nil, err
122		}
123		return b[:n], nil
124	}
125}
126func (dst *Duration) XXX_Merge(src proto.Message) {
127	xxx_messageInfo_Duration.Merge(dst, src)
128}
129func (m *Duration) XXX_Size() int {
130	return m.Size()
131}
132func (m *Duration) XXX_DiscardUnknown() {
133	xxx_messageInfo_Duration.DiscardUnknown(m)
134}
135
136var xxx_messageInfo_Duration proto.InternalMessageInfo
137
138func (m *Duration) GetSeconds() int64 {
139	if m != nil {
140		return m.Seconds
141	}
142	return 0
143}
144
145func (m *Duration) GetNanos() int32 {
146	if m != nil {
147		return m.Nanos
148	}
149	return 0
150}
151
152func (*Duration) XXX_MessageName() string {
153	return "google.protobuf.Duration"
154}
155func init() {
156	proto.RegisterType((*Duration)(nil), "google.protobuf.Duration")
157}
158func (this *Duration) Compare(that interface{}) int {
159	if that == nil {
160		if this == nil {
161			return 0
162		}
163		return 1
164	}
165
166	that1, ok := that.(*Duration)
167	if !ok {
168		that2, ok := that.(Duration)
169		if ok {
170			that1 = &that2
171		} else {
172			return 1
173		}
174	}
175	if that1 == nil {
176		if this == nil {
177			return 0
178		}
179		return 1
180	} else if this == nil {
181		return -1
182	}
183	if this.Seconds != that1.Seconds {
184		if this.Seconds < that1.Seconds {
185			return -1
186		}
187		return 1
188	}
189	if this.Nanos != that1.Nanos {
190		if this.Nanos < that1.Nanos {
191			return -1
192		}
193		return 1
194	}
195	if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 {
196		return c
197	}
198	return 0
199}
200func (this *Duration) Equal(that interface{}) bool {
201	if that == nil {
202		return this == nil
203	}
204
205	that1, ok := that.(*Duration)
206	if !ok {
207		that2, ok := that.(Duration)
208		if ok {
209			that1 = &that2
210		} else {
211			return false
212		}
213	}
214	if that1 == nil {
215		return this == nil
216	} else if this == nil {
217		return false
218	}
219	if this.Seconds != that1.Seconds {
220		return false
221	}
222	if this.Nanos != that1.Nanos {
223		return false
224	}
225	if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) {
226		return false
227	}
228	return true
229}
230func (this *Duration) GoString() string {
231	if this == nil {
232		return "nil"
233	}
234	s := make([]string, 0, 6)
235	s = append(s, "&types.Duration{")
236	s = append(s, "Seconds: "+fmt.Sprintf("%#v", this.Seconds)+",\n")
237	s = append(s, "Nanos: "+fmt.Sprintf("%#v", this.Nanos)+",\n")
238	if this.XXX_unrecognized != nil {
239		s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n")
240	}
241	s = append(s, "}")
242	return strings.Join(s, "")
243}
244func valueToGoStringDuration(v interface{}, typ string) string {
245	rv := reflect.ValueOf(v)
246	if rv.IsNil() {
247		return "nil"
248	}
249	pv := reflect.Indirect(rv).Interface()
250	return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv)
251}
252func (m *Duration) Marshal() (dAtA []byte, err error) {
253	size := m.Size()
254	dAtA = make([]byte, size)
255	n, err := m.MarshalTo(dAtA)
256	if err != nil {
257		return nil, err
258	}
259	return dAtA[:n], nil
260}
261
262func (m *Duration) MarshalTo(dAtA []byte) (int, error) {
263	var i int
264	_ = i
265	var l int
266	_ = l
267	if m.Seconds != 0 {
268		dAtA[i] = 0x8
269		i++
270		i = encodeVarintDuration(dAtA, i, uint64(m.Seconds))
271	}
272	if m.Nanos != 0 {
273		dAtA[i] = 0x10
274		i++
275		i = encodeVarintDuration(dAtA, i, uint64(m.Nanos))
276	}
277	if m.XXX_unrecognized != nil {
278		i += copy(dAtA[i:], m.XXX_unrecognized)
279	}
280	return i, nil
281}
282
283func encodeVarintDuration(dAtA []byte, offset int, v uint64) int {
284	for v >= 1<<7 {
285		dAtA[offset] = uint8(v&0x7f | 0x80)
286		v >>= 7
287		offset++
288	}
289	dAtA[offset] = uint8(v)
290	return offset + 1
291}
292func (m *Duration) Size() (n int) {
293	var l int
294	_ = l
295	if m.Seconds != 0 {
296		n += 1 + sovDuration(uint64(m.Seconds))
297	}
298	if m.Nanos != 0 {
299		n += 1 + sovDuration(uint64(m.Nanos))
300	}
301	if m.XXX_unrecognized != nil {
302		n += len(m.XXX_unrecognized)
303	}
304	return n
305}
306
307func sovDuration(x uint64) (n int) {
308	for {
309		n++
310		x >>= 7
311		if x == 0 {
312			break
313		}
314	}
315	return n
316}
317func sozDuration(x uint64) (n int) {
318	return sovDuration(uint64((x << 1) ^ uint64((int64(x) >> 63))))
319}
320func (m *Duration) Unmarshal(dAtA []byte) error {
321	l := len(dAtA)
322	iNdEx := 0
323	for iNdEx < l {
324		preIndex := iNdEx
325		var wire uint64
326		for shift := uint(0); ; shift += 7 {
327			if shift >= 64 {
328				return ErrIntOverflowDuration
329			}
330			if iNdEx >= l {
331				return io.ErrUnexpectedEOF
332			}
333			b := dAtA[iNdEx]
334			iNdEx++
335			wire |= (uint64(b) & 0x7F) << shift
336			if b < 0x80 {
337				break
338			}
339		}
340		fieldNum := int32(wire >> 3)
341		wireType := int(wire & 0x7)
342		if wireType == 4 {
343			return fmt.Errorf("proto: Duration: wiretype end group for non-group")
344		}
345		if fieldNum <= 0 {
346			return fmt.Errorf("proto: Duration: illegal tag %d (wire type %d)", fieldNum, wire)
347		}
348		switch fieldNum {
349		case 1:
350			if wireType != 0 {
351				return fmt.Errorf("proto: wrong wireType = %d for field Seconds", wireType)
352			}
353			m.Seconds = 0
354			for shift := uint(0); ; shift += 7 {
355				if shift >= 64 {
356					return ErrIntOverflowDuration
357				}
358				if iNdEx >= l {
359					return io.ErrUnexpectedEOF
360				}
361				b := dAtA[iNdEx]
362				iNdEx++
363				m.Seconds |= (int64(b) & 0x7F) << shift
364				if b < 0x80 {
365					break
366				}
367			}
368		case 2:
369			if wireType != 0 {
370				return fmt.Errorf("proto: wrong wireType = %d for field Nanos", wireType)
371			}
372			m.Nanos = 0
373			for shift := uint(0); ; shift += 7 {
374				if shift >= 64 {
375					return ErrIntOverflowDuration
376				}
377				if iNdEx >= l {
378					return io.ErrUnexpectedEOF
379				}
380				b := dAtA[iNdEx]
381				iNdEx++
382				m.Nanos |= (int32(b) & 0x7F) << shift
383				if b < 0x80 {
384					break
385				}
386			}
387		default:
388			iNdEx = preIndex
389			skippy, err := skipDuration(dAtA[iNdEx:])
390			if err != nil {
391				return err
392			}
393			if skippy < 0 {
394				return ErrInvalidLengthDuration
395			}
396			if (iNdEx + skippy) > l {
397				return io.ErrUnexpectedEOF
398			}
399			m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
400			iNdEx += skippy
401		}
402	}
403
404	if iNdEx > l {
405		return io.ErrUnexpectedEOF
406	}
407	return nil
408}
409func skipDuration(dAtA []byte) (n int, err error) {
410	l := len(dAtA)
411	iNdEx := 0
412	for iNdEx < l {
413		var wire uint64
414		for shift := uint(0); ; shift += 7 {
415			if shift >= 64 {
416				return 0, ErrIntOverflowDuration
417			}
418			if iNdEx >= l {
419				return 0, io.ErrUnexpectedEOF
420			}
421			b := dAtA[iNdEx]
422			iNdEx++
423			wire |= (uint64(b) & 0x7F) << shift
424			if b < 0x80 {
425				break
426			}
427		}
428		wireType := int(wire & 0x7)
429		switch wireType {
430		case 0:
431			for shift := uint(0); ; shift += 7 {
432				if shift >= 64 {
433					return 0, ErrIntOverflowDuration
434				}
435				if iNdEx >= l {
436					return 0, io.ErrUnexpectedEOF
437				}
438				iNdEx++
439				if dAtA[iNdEx-1] < 0x80 {
440					break
441				}
442			}
443			return iNdEx, nil
444		case 1:
445			iNdEx += 8
446			return iNdEx, nil
447		case 2:
448			var length int
449			for shift := uint(0); ; shift += 7 {
450				if shift >= 64 {
451					return 0, ErrIntOverflowDuration
452				}
453				if iNdEx >= l {
454					return 0, io.ErrUnexpectedEOF
455				}
456				b := dAtA[iNdEx]
457				iNdEx++
458				length |= (int(b) & 0x7F) << shift
459				if b < 0x80 {
460					break
461				}
462			}
463			iNdEx += length
464			if length < 0 {
465				return 0, ErrInvalidLengthDuration
466			}
467			return iNdEx, nil
468		case 3:
469			for {
470				var innerWire uint64
471				var start int = iNdEx
472				for shift := uint(0); ; shift += 7 {
473					if shift >= 64 {
474						return 0, ErrIntOverflowDuration
475					}
476					if iNdEx >= l {
477						return 0, io.ErrUnexpectedEOF
478					}
479					b := dAtA[iNdEx]
480					iNdEx++
481					innerWire |= (uint64(b) & 0x7F) << shift
482					if b < 0x80 {
483						break
484					}
485				}
486				innerWireType := int(innerWire & 0x7)
487				if innerWireType == 4 {
488					break
489				}
490				next, err := skipDuration(dAtA[start:])
491				if err != nil {
492					return 0, err
493				}
494				iNdEx = start + next
495			}
496			return iNdEx, nil
497		case 4:
498			return iNdEx, nil
499		case 5:
500			iNdEx += 4
501			return iNdEx, nil
502		default:
503			return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
504		}
505	}
506	panic("unreachable")
507}
508
509var (
510	ErrInvalidLengthDuration = fmt.Errorf("proto: negative length found during unmarshaling")
511	ErrIntOverflowDuration   = fmt.Errorf("proto: integer overflow")
512)
513
514func init() {
515	proto.RegisterFile("google/protobuf/duration.proto", fileDescriptor_duration_7f04bf66a647e6f6)
516}
517
518var fileDescriptor_duration_7f04bf66a647e6f6 = []byte{
519	// 215 bytes of a gzipped FileDescriptorProto
520	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4b, 0xcf, 0xcf, 0x4f,
521	0xcf, 0x49, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x4f, 0x29, 0x2d, 0x4a,
522	0x2c, 0xc9, 0xcc, 0xcf, 0xd3, 0x03, 0x8b, 0x08, 0xf1, 0x43, 0xe4, 0xf5, 0x60, 0xf2, 0x4a, 0x56,
523	0x5c, 0x1c, 0x2e, 0x50, 0x25, 0x42, 0x12, 0x5c, 0xec, 0xc5, 0xa9, 0xc9, 0xf9, 0x79, 0x29, 0xc5,
524	0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0xcc, 0x41, 0x30, 0xae, 0x90, 0x08, 0x17, 0x6b, 0x5e, 0x62, 0x5e,
525	0x7e, 0xb1, 0x04, 0x93, 0x02, 0xa3, 0x06, 0x6b, 0x10, 0x84, 0xe3, 0xd4, 0xcc, 0x78, 0xe1, 0xa1,
526	0x1c, 0xc3, 0x8d, 0x87, 0x72, 0x0c, 0x1f, 0x1e, 0xca, 0x31, 0xae, 0x78, 0x24, 0xc7, 0x78, 0xe2,
527	0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0xbe, 0x78, 0x24, 0xc7, 0xf0,
528	0xe1, 0x91, 0x1c, 0xe3, 0x8a, 0xc7, 0x72, 0x8c, 0x27, 0x1e, 0xcb, 0x31, 0x72, 0x09, 0x27, 0xe7,
529	0xe7, 0xea, 0xa1, 0xd9, 0xef, 0xc4, 0x0b, 0xb3, 0x3d, 0x00, 0x24, 0x12, 0xc0, 0x18, 0xc5, 0x5a,
530	0x52, 0x59, 0x90, 0x5a, 0xfc, 0x83, 0x91, 0x71, 0x11, 0x13, 0xb3, 0x7b, 0x80, 0xd3, 0x2a, 0x26,
531	0x39, 0x77, 0x88, 0x96, 0x00, 0xa8, 0x16, 0xbd, 0xf0, 0xd4, 0x9c, 0x1c, 0xef, 0xbc, 0xfc, 0xf2,
532	0xbc, 0x10, 0x90, 0xca, 0x24, 0x36, 0xb0, 0x59, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7d,
533	0xb1, 0xa3, 0x66, 0xfb, 0x00, 0x00, 0x00,
534}
535