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