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_187e4d5f80a83848, []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 if m == nil { 294 return 0 295 } 296 var l int 297 _ = l 298 if m.Seconds != 0 { 299 n += 1 + sovDuration(uint64(m.Seconds)) 300 } 301 if m.Nanos != 0 { 302 n += 1 + sovDuration(uint64(m.Nanos)) 303 } 304 if m.XXX_unrecognized != nil { 305 n += len(m.XXX_unrecognized) 306 } 307 return n 308} 309 310func sovDuration(x uint64) (n int) { 311 for { 312 n++ 313 x >>= 7 314 if x == 0 { 315 break 316 } 317 } 318 return n 319} 320func sozDuration(x uint64) (n int) { 321 return sovDuration(uint64((x << 1) ^ uint64((int64(x) >> 63)))) 322} 323func (m *Duration) Unmarshal(dAtA []byte) error { 324 l := len(dAtA) 325 iNdEx := 0 326 for iNdEx < l { 327 preIndex := iNdEx 328 var wire uint64 329 for shift := uint(0); ; shift += 7 { 330 if shift >= 64 { 331 return ErrIntOverflowDuration 332 } 333 if iNdEx >= l { 334 return io.ErrUnexpectedEOF 335 } 336 b := dAtA[iNdEx] 337 iNdEx++ 338 wire |= (uint64(b) & 0x7F) << shift 339 if b < 0x80 { 340 break 341 } 342 } 343 fieldNum := int32(wire >> 3) 344 wireType := int(wire & 0x7) 345 if wireType == 4 { 346 return fmt.Errorf("proto: Duration: wiretype end group for non-group") 347 } 348 if fieldNum <= 0 { 349 return fmt.Errorf("proto: Duration: illegal tag %d (wire type %d)", fieldNum, wire) 350 } 351 switch fieldNum { 352 case 1: 353 if wireType != 0 { 354 return fmt.Errorf("proto: wrong wireType = %d for field Seconds", wireType) 355 } 356 m.Seconds = 0 357 for shift := uint(0); ; shift += 7 { 358 if shift >= 64 { 359 return ErrIntOverflowDuration 360 } 361 if iNdEx >= l { 362 return io.ErrUnexpectedEOF 363 } 364 b := dAtA[iNdEx] 365 iNdEx++ 366 m.Seconds |= (int64(b) & 0x7F) << shift 367 if b < 0x80 { 368 break 369 } 370 } 371 case 2: 372 if wireType != 0 { 373 return fmt.Errorf("proto: wrong wireType = %d for field Nanos", wireType) 374 } 375 m.Nanos = 0 376 for shift := uint(0); ; shift += 7 { 377 if shift >= 64 { 378 return ErrIntOverflowDuration 379 } 380 if iNdEx >= l { 381 return io.ErrUnexpectedEOF 382 } 383 b := dAtA[iNdEx] 384 iNdEx++ 385 m.Nanos |= (int32(b) & 0x7F) << shift 386 if b < 0x80 { 387 break 388 } 389 } 390 default: 391 iNdEx = preIndex 392 skippy, err := skipDuration(dAtA[iNdEx:]) 393 if err != nil { 394 return err 395 } 396 if skippy < 0 { 397 return ErrInvalidLengthDuration 398 } 399 if (iNdEx + skippy) > l { 400 return io.ErrUnexpectedEOF 401 } 402 m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) 403 iNdEx += skippy 404 } 405 } 406 407 if iNdEx > l { 408 return io.ErrUnexpectedEOF 409 } 410 return nil 411} 412func skipDuration(dAtA []byte) (n int, err error) { 413 l := len(dAtA) 414 iNdEx := 0 415 for iNdEx < l { 416 var wire uint64 417 for shift := uint(0); ; shift += 7 { 418 if shift >= 64 { 419 return 0, ErrIntOverflowDuration 420 } 421 if iNdEx >= l { 422 return 0, io.ErrUnexpectedEOF 423 } 424 b := dAtA[iNdEx] 425 iNdEx++ 426 wire |= (uint64(b) & 0x7F) << shift 427 if b < 0x80 { 428 break 429 } 430 } 431 wireType := int(wire & 0x7) 432 switch wireType { 433 case 0: 434 for shift := uint(0); ; shift += 7 { 435 if shift >= 64 { 436 return 0, ErrIntOverflowDuration 437 } 438 if iNdEx >= l { 439 return 0, io.ErrUnexpectedEOF 440 } 441 iNdEx++ 442 if dAtA[iNdEx-1] < 0x80 { 443 break 444 } 445 } 446 return iNdEx, nil 447 case 1: 448 iNdEx += 8 449 return iNdEx, nil 450 case 2: 451 var length int 452 for shift := uint(0); ; shift += 7 { 453 if shift >= 64 { 454 return 0, ErrIntOverflowDuration 455 } 456 if iNdEx >= l { 457 return 0, io.ErrUnexpectedEOF 458 } 459 b := dAtA[iNdEx] 460 iNdEx++ 461 length |= (int(b) & 0x7F) << shift 462 if b < 0x80 { 463 break 464 } 465 } 466 iNdEx += length 467 if length < 0 { 468 return 0, ErrInvalidLengthDuration 469 } 470 return iNdEx, nil 471 case 3: 472 for { 473 var innerWire uint64 474 var start int = iNdEx 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 innerWire |= (uint64(b) & 0x7F) << shift 485 if b < 0x80 { 486 break 487 } 488 } 489 innerWireType := int(innerWire & 0x7) 490 if innerWireType == 4 { 491 break 492 } 493 next, err := skipDuration(dAtA[start:]) 494 if err != nil { 495 return 0, err 496 } 497 iNdEx = start + next 498 } 499 return iNdEx, nil 500 case 4: 501 return iNdEx, nil 502 case 5: 503 iNdEx += 4 504 return iNdEx, nil 505 default: 506 return 0, fmt.Errorf("proto: illegal wireType %d", wireType) 507 } 508 } 509 panic("unreachable") 510} 511 512var ( 513 ErrInvalidLengthDuration = fmt.Errorf("proto: negative length found during unmarshaling") 514 ErrIntOverflowDuration = fmt.Errorf("proto: integer overflow") 515) 516 517func init() { 518 proto.RegisterFile("google/protobuf/duration.proto", fileDescriptor_duration_187e4d5f80a83848) 519} 520 521var fileDescriptor_duration_187e4d5f80a83848 = []byte{ 522 // 209 bytes of a gzipped FileDescriptorProto 523 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4b, 0xcf, 0xcf, 0x4f, 524 0xcf, 0x49, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0x2a, 0x4d, 0xd3, 0x4f, 0x29, 0x2d, 0x4a, 525 0x2c, 0xc9, 0xcc, 0xcf, 0xd3, 0x03, 0x8b, 0x08, 0xf1, 0x43, 0xe4, 0xf5, 0x60, 0xf2, 0x4a, 0x56, 526 0x5c, 0x1c, 0x2e, 0x50, 0x25, 0x42, 0x12, 0x5c, 0xec, 0xc5, 0xa9, 0xc9, 0xf9, 0x79, 0x29, 0xc5, 527 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0xcc, 0x41, 0x30, 0xae, 0x90, 0x08, 0x17, 0x6b, 0x5e, 0x62, 0x5e, 528 0x7e, 0xb1, 0x04, 0x93, 0x02, 0xa3, 0x06, 0x6b, 0x10, 0x84, 0xe3, 0x54, 0x7f, 0xe3, 0xa1, 0x1c, 529 0xc3, 0x87, 0x87, 0x72, 0x8c, 0x2b, 0x1e, 0xc9, 0x31, 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 530 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x2f, 0x1e, 0xc9, 0x31, 0x7c, 0x78, 0x24, 0xc7, 0xb8, 0xe2, 531 0xb1, 0x1c, 0xe3, 0x89, 0xc7, 0x72, 0x8c, 0x5c, 0xc2, 0xc9, 0xf9, 0xb9, 0x7a, 0x68, 0x56, 0x3b, 532 0xf1, 0xc2, 0x2c, 0x0e, 0x00, 0x89, 0x04, 0x30, 0x46, 0xb1, 0x96, 0x54, 0x16, 0xa4, 0x16, 0xff, 533 0x60, 0x64, 0x5c, 0xc4, 0xc4, 0xec, 0x1e, 0xe0, 0xb4, 0x8a, 0x49, 0xce, 0x1d, 0xa2, 0x25, 0x00, 534 0xaa, 0x45, 0x2f, 0x3c, 0x35, 0x27, 0xc7, 0x3b, 0x2f, 0xbf, 0x3c, 0x2f, 0x04, 0xa4, 0x32, 0x89, 535 0x0d, 0x6c, 0x96, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x8a, 0x1c, 0x64, 0x4e, 0xf6, 0x00, 0x00, 536 0x00, 537} 538