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 math_bits "math/bits" 13 reflect "reflect" 14 strings "strings" 15) 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.GoGoProtoPackageIsVersion3 // 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_23597b2ebd7ac6c5, []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.MarshalToSizedBuffer(b) 120 if err != nil { 121 return nil, err 122 } 123 return b[:n], nil 124 } 125} 126func (m *Duration) XXX_Merge(src proto.Message) { 127 xxx_messageInfo_Duration.Merge(m, 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} 158 159func init() { proto.RegisterFile("google/protobuf/duration.proto", fileDescriptor_23597b2ebd7ac6c5) } 160 161var fileDescriptor_23597b2ebd7ac6c5 = []byte{ 162 // 209 bytes of a gzipped FileDescriptorProto 163 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4b, 0xcf, 0xcf, 0x4f, 164 0xcf, 0x49, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x4f, 0x29, 0x2d, 0x4a, 165 0x2c, 0xc9, 0xcc, 0xcf, 0xd3, 0x03, 0x8b, 0x08, 0xf1, 0x43, 0xe4, 0xf5, 0x60, 0xf2, 0x4a, 0x56, 166 0x5c, 0x1c, 0x2e, 0x50, 0x25, 0x42, 0x12, 0x5c, 0xec, 0xc5, 0xa9, 0xc9, 0xf9, 0x79, 0x29, 0xc5, 167 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0xcc, 0x41, 0x30, 0xae, 0x90, 0x08, 0x17, 0x6b, 0x5e, 0x62, 0x5e, 168 0x7e, 0xb1, 0x04, 0x93, 0x02, 0xa3, 0x06, 0x6b, 0x10, 0x84, 0xe3, 0x54, 0x7f, 0xe3, 0xa1, 0x1c, 169 0xc3, 0x87, 0x87, 0x72, 0x8c, 0x2b, 0x1e, 0xc9, 0x31, 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 170 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x2f, 0x1e, 0xc9, 0x31, 0x7c, 0x78, 0x24, 0xc7, 0xb8, 0xe2, 171 0xb1, 0x1c, 0xe3, 0x89, 0xc7, 0x72, 0x8c, 0x5c, 0xc2, 0xc9, 0xf9, 0xb9, 0x7a, 0x68, 0x56, 0x3b, 172 0xf1, 0xc2, 0x2c, 0x0e, 0x00, 0x89, 0x04, 0x30, 0x46, 0xb1, 0x96, 0x54, 0x16, 0xa4, 0x16, 0xff, 173 0x60, 0x64, 0x5c, 0xc4, 0xc4, 0xec, 0x1e, 0xe0, 0xb4, 0x8a, 0x49, 0xce, 0x1d, 0xa2, 0x25, 0x00, 174 0xaa, 0x45, 0x2f, 0x3c, 0x35, 0x27, 0xc7, 0x3b, 0x2f, 0xbf, 0x3c, 0x2f, 0x04, 0xa4, 0x32, 0x89, 175 0x0d, 0x6c, 0x96, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x8a, 0x1c, 0x64, 0x4e, 0xf6, 0x00, 0x00, 176 0x00, 177} 178 179func (this *Duration) Compare(that interface{}) int { 180 if that == nil { 181 if this == nil { 182 return 0 183 } 184 return 1 185 } 186 187 that1, ok := that.(*Duration) 188 if !ok { 189 that2, ok := that.(Duration) 190 if ok { 191 that1 = &that2 192 } else { 193 return 1 194 } 195 } 196 if that1 == nil { 197 if this == nil { 198 return 0 199 } 200 return 1 201 } else if this == nil { 202 return -1 203 } 204 if this.Seconds != that1.Seconds { 205 if this.Seconds < that1.Seconds { 206 return -1 207 } 208 return 1 209 } 210 if this.Nanos != that1.Nanos { 211 if this.Nanos < that1.Nanos { 212 return -1 213 } 214 return 1 215 } 216 if c := bytes.Compare(this.XXX_unrecognized, that1.XXX_unrecognized); c != 0 { 217 return c 218 } 219 return 0 220} 221func (this *Duration) Equal(that interface{}) bool { 222 if that == nil { 223 return this == nil 224 } 225 226 that1, ok := that.(*Duration) 227 if !ok { 228 that2, ok := that.(Duration) 229 if ok { 230 that1 = &that2 231 } else { 232 return false 233 } 234 } 235 if that1 == nil { 236 return this == nil 237 } else if this == nil { 238 return false 239 } 240 if this.Seconds != that1.Seconds { 241 return false 242 } 243 if this.Nanos != that1.Nanos { 244 return false 245 } 246 if !bytes.Equal(this.XXX_unrecognized, that1.XXX_unrecognized) { 247 return false 248 } 249 return true 250} 251func (this *Duration) GoString() string { 252 if this == nil { 253 return "nil" 254 } 255 s := make([]string, 0, 6) 256 s = append(s, "&types.Duration{") 257 s = append(s, "Seconds: "+fmt.Sprintf("%#v", this.Seconds)+",\n") 258 s = append(s, "Nanos: "+fmt.Sprintf("%#v", this.Nanos)+",\n") 259 if this.XXX_unrecognized != nil { 260 s = append(s, "XXX_unrecognized:"+fmt.Sprintf("%#v", this.XXX_unrecognized)+",\n") 261 } 262 s = append(s, "}") 263 return strings.Join(s, "") 264} 265func valueToGoStringDuration(v interface{}, typ string) string { 266 rv := reflect.ValueOf(v) 267 if rv.IsNil() { 268 return "nil" 269 } 270 pv := reflect.Indirect(rv).Interface() 271 return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv) 272} 273func (m *Duration) Marshal() (dAtA []byte, err error) { 274 size := m.Size() 275 dAtA = make([]byte, size) 276 n, err := m.MarshalToSizedBuffer(dAtA[:size]) 277 if err != nil { 278 return nil, err 279 } 280 return dAtA[:n], nil 281} 282 283func (m *Duration) MarshalTo(dAtA []byte) (int, error) { 284 size := m.Size() 285 return m.MarshalToSizedBuffer(dAtA[:size]) 286} 287 288func (m *Duration) MarshalToSizedBuffer(dAtA []byte) (int, error) { 289 i := len(dAtA) 290 _ = i 291 var l int 292 _ = l 293 if m.XXX_unrecognized != nil { 294 i -= len(m.XXX_unrecognized) 295 copy(dAtA[i:], m.XXX_unrecognized) 296 } 297 if m.Nanos != 0 { 298 i = encodeVarintDuration(dAtA, i, uint64(m.Nanos)) 299 i-- 300 dAtA[i] = 0x10 301 } 302 if m.Seconds != 0 { 303 i = encodeVarintDuration(dAtA, i, uint64(m.Seconds)) 304 i-- 305 dAtA[i] = 0x8 306 } 307 return len(dAtA) - i, nil 308} 309 310func encodeVarintDuration(dAtA []byte, offset int, v uint64) int { 311 offset -= sovDuration(v) 312 base := offset 313 for v >= 1<<7 { 314 dAtA[offset] = uint8(v&0x7f | 0x80) 315 v >>= 7 316 offset++ 317 } 318 dAtA[offset] = uint8(v) 319 return base 320} 321func (m *Duration) Size() (n int) { 322 if m == nil { 323 return 0 324 } 325 var l int 326 _ = l 327 if m.Seconds != 0 { 328 n += 1 + sovDuration(uint64(m.Seconds)) 329 } 330 if m.Nanos != 0 { 331 n += 1 + sovDuration(uint64(m.Nanos)) 332 } 333 if m.XXX_unrecognized != nil { 334 n += len(m.XXX_unrecognized) 335 } 336 return n 337} 338 339func sovDuration(x uint64) (n int) { 340 return (math_bits.Len64(x|1) + 6) / 7 341} 342func sozDuration(x uint64) (n int) { 343 return sovDuration(uint64((x << 1) ^ uint64((int64(x) >> 63)))) 344} 345func (m *Duration) Unmarshal(dAtA []byte) error { 346 l := len(dAtA) 347 iNdEx := 0 348 for iNdEx < l { 349 preIndex := iNdEx 350 var wire uint64 351 for shift := uint(0); ; shift += 7 { 352 if shift >= 64 { 353 return ErrIntOverflowDuration 354 } 355 if iNdEx >= l { 356 return io.ErrUnexpectedEOF 357 } 358 b := dAtA[iNdEx] 359 iNdEx++ 360 wire |= uint64(b&0x7F) << shift 361 if b < 0x80 { 362 break 363 } 364 } 365 fieldNum := int32(wire >> 3) 366 wireType := int(wire & 0x7) 367 if wireType == 4 { 368 return fmt.Errorf("proto: Duration: wiretype end group for non-group") 369 } 370 if fieldNum <= 0 { 371 return fmt.Errorf("proto: Duration: illegal tag %d (wire type %d)", fieldNum, wire) 372 } 373 switch fieldNum { 374 case 1: 375 if wireType != 0 { 376 return fmt.Errorf("proto: wrong wireType = %d for field Seconds", wireType) 377 } 378 m.Seconds = 0 379 for shift := uint(0); ; shift += 7 { 380 if shift >= 64 { 381 return ErrIntOverflowDuration 382 } 383 if iNdEx >= l { 384 return io.ErrUnexpectedEOF 385 } 386 b := dAtA[iNdEx] 387 iNdEx++ 388 m.Seconds |= int64(b&0x7F) << shift 389 if b < 0x80 { 390 break 391 } 392 } 393 case 2: 394 if wireType != 0 { 395 return fmt.Errorf("proto: wrong wireType = %d for field Nanos", wireType) 396 } 397 m.Nanos = 0 398 for shift := uint(0); ; shift += 7 { 399 if shift >= 64 { 400 return ErrIntOverflowDuration 401 } 402 if iNdEx >= l { 403 return io.ErrUnexpectedEOF 404 } 405 b := dAtA[iNdEx] 406 iNdEx++ 407 m.Nanos |= int32(b&0x7F) << shift 408 if b < 0x80 { 409 break 410 } 411 } 412 default: 413 iNdEx = preIndex 414 skippy, err := skipDuration(dAtA[iNdEx:]) 415 if err != nil { 416 return err 417 } 418 if skippy < 0 { 419 return ErrInvalidLengthDuration 420 } 421 if (iNdEx + skippy) < 0 { 422 return ErrInvalidLengthDuration 423 } 424 if (iNdEx + skippy) > l { 425 return io.ErrUnexpectedEOF 426 } 427 m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) 428 iNdEx += skippy 429 } 430 } 431 432 if iNdEx > l { 433 return io.ErrUnexpectedEOF 434 } 435 return nil 436} 437func skipDuration(dAtA []byte) (n int, err error) { 438 l := len(dAtA) 439 iNdEx := 0 440 depth := 0 441 for iNdEx < l { 442 var wire uint64 443 for shift := uint(0); ; shift += 7 { 444 if shift >= 64 { 445 return 0, ErrIntOverflowDuration 446 } 447 if iNdEx >= l { 448 return 0, io.ErrUnexpectedEOF 449 } 450 b := dAtA[iNdEx] 451 iNdEx++ 452 wire |= (uint64(b) & 0x7F) << shift 453 if b < 0x80 { 454 break 455 } 456 } 457 wireType := int(wire & 0x7) 458 switch wireType { 459 case 0: 460 for shift := uint(0); ; shift += 7 { 461 if shift >= 64 { 462 return 0, ErrIntOverflowDuration 463 } 464 if iNdEx >= l { 465 return 0, io.ErrUnexpectedEOF 466 } 467 iNdEx++ 468 if dAtA[iNdEx-1] < 0x80 { 469 break 470 } 471 } 472 case 1: 473 iNdEx += 8 474 case 2: 475 var length int 476 for shift := uint(0); ; shift += 7 { 477 if shift >= 64 { 478 return 0, ErrIntOverflowDuration 479 } 480 if iNdEx >= l { 481 return 0, io.ErrUnexpectedEOF 482 } 483 b := dAtA[iNdEx] 484 iNdEx++ 485 length |= (int(b) & 0x7F) << shift 486 if b < 0x80 { 487 break 488 } 489 } 490 if length < 0 { 491 return 0, ErrInvalidLengthDuration 492 } 493 iNdEx += length 494 case 3: 495 depth++ 496 case 4: 497 if depth == 0 { 498 return 0, ErrUnexpectedEndOfGroupDuration 499 } 500 depth-- 501 case 5: 502 iNdEx += 4 503 default: 504 return 0, fmt.Errorf("proto: illegal wireType %d", wireType) 505 } 506 if iNdEx < 0 { 507 return 0, ErrInvalidLengthDuration 508 } 509 if depth == 0 { 510 return iNdEx, nil 511 } 512 } 513 return 0, io.ErrUnexpectedEOF 514} 515 516var ( 517 ErrInvalidLengthDuration = fmt.Errorf("proto: negative length found during unmarshaling") 518 ErrIntOverflowDuration = fmt.Errorf("proto: integer overflow") 519 ErrUnexpectedEndOfGroupDuration = fmt.Errorf("proto: unexpected end of group") 520) 521