PageRenderTime 49ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/github.com/gogo/protobuf/types/duration.pb.go

https://gitlab.com/unofficial-mirrors/kubernetes
Go | 500 lines | 406 code | 20 blank | 74 comment | 109 complexity | 707e400b5d06b38baeb1fc1c4b23297e MD5 | raw file
  1. // Code generated by protoc-gen-gogo.
  2. // source: duration.proto
  3. // DO NOT EDIT!
  4. /*
  5. Package types is a generated protocol buffer package.
  6. It is generated from these files:
  7. duration.proto
  8. It has these top-level messages:
  9. Duration
  10. */
  11. package types
  12. import proto "github.com/gogo/protobuf/proto"
  13. import fmt "fmt"
  14. import math "math"
  15. import strings "strings"
  16. import reflect "reflect"
  17. import io "io"
  18. // Reference imports to suppress errors if they are not otherwise used.
  19. var _ = proto.Marshal
  20. var _ = fmt.Errorf
  21. var _ = math.Inf
  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.
  26. const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
  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. // Example 1: Compute Duration from two Timestamps in pseudo code.
  35. //
  36. // Timestamp start = ...;
  37. // Timestamp end = ...;
  38. // Duration duration = ...;
  39. //
  40. // duration.seconds = end.seconds - start.seconds;
  41. // duration.nanos = end.nanos - start.nanos;
  42. //
  43. // if (duration.seconds < 0 && duration.nanos > 0) {
  44. // duration.seconds += 1;
  45. // duration.nanos -= 1000000000;
  46. // } else if (durations.seconds > 0 && duration.nanos < 0) {
  47. // duration.seconds -= 1;
  48. // duration.nanos += 1000000000;
  49. // }
  50. //
  51. // Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
  52. //
  53. // Timestamp start = ...;
  54. // Duration duration = ...;
  55. // Timestamp end = ...;
  56. //
  57. // end.seconds = start.seconds + duration.seconds;
  58. // end.nanos = start.nanos + duration.nanos;
  59. //
  60. // if (end.nanos < 0) {
  61. // end.seconds -= 1;
  62. // end.nanos += 1000000000;
  63. // } else if (end.nanos >= 1000000000) {
  64. // end.seconds += 1;
  65. // end.nanos -= 1000000000;
  66. // }
  67. //
  68. // Example 3: Compute Duration from datetime.timedelta in Python.
  69. //
  70. // td = datetime.timedelta(days=3, minutes=10)
  71. // duration = Duration()
  72. // duration.FromTimedelta(td)
  73. //
  74. //
  75. type Duration struct {
  76. // Signed seconds of the span of time. Must be from -315,576,000,000
  77. // to +315,576,000,000 inclusive.
  78. Seconds int64 `protobuf:"varint,1,opt,name=seconds,proto3" json:"seconds,omitempty"`
  79. // Signed fractions of a second at nanosecond resolution of the span
  80. // of time. Durations less than one second are represented with a 0
  81. // `seconds` field and a positive or negative `nanos` field. For durations
  82. // of one second or more, a non-zero value for the `nanos` field must be
  83. // of the same sign as the `seconds` field. Must be from -999,999,999
  84. // to +999,999,999 inclusive.
  85. Nanos int32 `protobuf:"varint,2,opt,name=nanos,proto3" json:"nanos,omitempty"`
  86. }
  87. func (m *Duration) Reset() { *m = Duration{} }
  88. func (*Duration) ProtoMessage() {}
  89. func (*Duration) Descriptor() ([]byte, []int) { return fileDescriptorDuration, []int{0} }
  90. func (*Duration) XXX_WellKnownType() string { return "Duration" }
  91. func (m *Duration) GetSeconds() int64 {
  92. if m != nil {
  93. return m.Seconds
  94. }
  95. return 0
  96. }
  97. func (m *Duration) GetNanos() int32 {
  98. if m != nil {
  99. return m.Nanos
  100. }
  101. return 0
  102. }
  103. func init() {
  104. proto.RegisterType((*Duration)(nil), "google.protobuf.Duration")
  105. }
  106. func (this *Duration) Compare(that interface{}) int {
  107. if that == nil {
  108. if this == nil {
  109. return 0
  110. }
  111. return 1
  112. }
  113. that1, ok := that.(*Duration)
  114. if !ok {
  115. that2, ok := that.(Duration)
  116. if ok {
  117. that1 = &that2
  118. } else {
  119. return 1
  120. }
  121. }
  122. if that1 == nil {
  123. if this == nil {
  124. return 0
  125. }
  126. return 1
  127. } else if this == nil {
  128. return -1
  129. }
  130. if this.Seconds != that1.Seconds {
  131. if this.Seconds < that1.Seconds {
  132. return -1
  133. }
  134. return 1
  135. }
  136. if this.Nanos != that1.Nanos {
  137. if this.Nanos < that1.Nanos {
  138. return -1
  139. }
  140. return 1
  141. }
  142. return 0
  143. }
  144. func (this *Duration) Equal(that interface{}) bool {
  145. if that == nil {
  146. if this == nil {
  147. return true
  148. }
  149. return false
  150. }
  151. that1, ok := that.(*Duration)
  152. if !ok {
  153. that2, ok := that.(Duration)
  154. if ok {
  155. that1 = &that2
  156. } else {
  157. return false
  158. }
  159. }
  160. if that1 == nil {
  161. if this == nil {
  162. return true
  163. }
  164. return false
  165. } else if this == nil {
  166. return false
  167. }
  168. if this.Seconds != that1.Seconds {
  169. return false
  170. }
  171. if this.Nanos != that1.Nanos {
  172. return false
  173. }
  174. return true
  175. }
  176. func (this *Duration) GoString() string {
  177. if this == nil {
  178. return "nil"
  179. }
  180. s := make([]string, 0, 6)
  181. s = append(s, "&types.Duration{")
  182. s = append(s, "Seconds: "+fmt.Sprintf("%#v", this.Seconds)+",\n")
  183. s = append(s, "Nanos: "+fmt.Sprintf("%#v", this.Nanos)+",\n")
  184. s = append(s, "}")
  185. return strings.Join(s, "")
  186. }
  187. func valueToGoStringDuration(v interface{}, typ string) string {
  188. rv := reflect.ValueOf(v)
  189. if rv.IsNil() {
  190. return "nil"
  191. }
  192. pv := reflect.Indirect(rv).Interface()
  193. return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv)
  194. }
  195. func (m *Duration) Marshal() (dAtA []byte, err error) {
  196. size := m.Size()
  197. dAtA = make([]byte, size)
  198. n, err := m.MarshalTo(dAtA)
  199. if err != nil {
  200. return nil, err
  201. }
  202. return dAtA[:n], nil
  203. }
  204. func (m *Duration) MarshalTo(dAtA []byte) (int, error) {
  205. var i int
  206. _ = i
  207. var l int
  208. _ = l
  209. if m.Seconds != 0 {
  210. dAtA[i] = 0x8
  211. i++
  212. i = encodeVarintDuration(dAtA, i, uint64(m.Seconds))
  213. }
  214. if m.Nanos != 0 {
  215. dAtA[i] = 0x10
  216. i++
  217. i = encodeVarintDuration(dAtA, i, uint64(m.Nanos))
  218. }
  219. return i, nil
  220. }
  221. func encodeFixed64Duration(dAtA []byte, offset int, v uint64) int {
  222. dAtA[offset] = uint8(v)
  223. dAtA[offset+1] = uint8(v >> 8)
  224. dAtA[offset+2] = uint8(v >> 16)
  225. dAtA[offset+3] = uint8(v >> 24)
  226. dAtA[offset+4] = uint8(v >> 32)
  227. dAtA[offset+5] = uint8(v >> 40)
  228. dAtA[offset+6] = uint8(v >> 48)
  229. dAtA[offset+7] = uint8(v >> 56)
  230. return offset + 8
  231. }
  232. func encodeFixed32Duration(dAtA []byte, offset int, v uint32) int {
  233. dAtA[offset] = uint8(v)
  234. dAtA[offset+1] = uint8(v >> 8)
  235. dAtA[offset+2] = uint8(v >> 16)
  236. dAtA[offset+3] = uint8(v >> 24)
  237. return offset + 4
  238. }
  239. func encodeVarintDuration(dAtA []byte, offset int, v uint64) int {
  240. for v >= 1<<7 {
  241. dAtA[offset] = uint8(v&0x7f | 0x80)
  242. v >>= 7
  243. offset++
  244. }
  245. dAtA[offset] = uint8(v)
  246. return offset + 1
  247. }
  248. func (m *Duration) Size() (n int) {
  249. var l int
  250. _ = l
  251. if m.Seconds != 0 {
  252. n += 1 + sovDuration(uint64(m.Seconds))
  253. }
  254. if m.Nanos != 0 {
  255. n += 1 + sovDuration(uint64(m.Nanos))
  256. }
  257. return n
  258. }
  259. func sovDuration(x uint64) (n int) {
  260. for {
  261. n++
  262. x >>= 7
  263. if x == 0 {
  264. break
  265. }
  266. }
  267. return n
  268. }
  269. func sozDuration(x uint64) (n int) {
  270. return sovDuration(uint64((x << 1) ^ uint64((int64(x) >> 63))))
  271. }
  272. func (m *Duration) Unmarshal(dAtA []byte) error {
  273. l := len(dAtA)
  274. iNdEx := 0
  275. for iNdEx < l {
  276. preIndex := iNdEx
  277. var wire uint64
  278. for shift := uint(0); ; shift += 7 {
  279. if shift >= 64 {
  280. return ErrIntOverflowDuration
  281. }
  282. if iNdEx >= l {
  283. return io.ErrUnexpectedEOF
  284. }
  285. b := dAtA[iNdEx]
  286. iNdEx++
  287. wire |= (uint64(b) & 0x7F) << shift
  288. if b < 0x80 {
  289. break
  290. }
  291. }
  292. fieldNum := int32(wire >> 3)
  293. wireType := int(wire & 0x7)
  294. if wireType == 4 {
  295. return fmt.Errorf("proto: Duration: wiretype end group for non-group")
  296. }
  297. if fieldNum <= 0 {
  298. return fmt.Errorf("proto: Duration: illegal tag %d (wire type %d)", fieldNum, wire)
  299. }
  300. switch fieldNum {
  301. case 1:
  302. if wireType != 0 {
  303. return fmt.Errorf("proto: wrong wireType = %d for field Seconds", wireType)
  304. }
  305. m.Seconds = 0
  306. for shift := uint(0); ; shift += 7 {
  307. if shift >= 64 {
  308. return ErrIntOverflowDuration
  309. }
  310. if iNdEx >= l {
  311. return io.ErrUnexpectedEOF
  312. }
  313. b := dAtA[iNdEx]
  314. iNdEx++
  315. m.Seconds |= (int64(b) & 0x7F) << shift
  316. if b < 0x80 {
  317. break
  318. }
  319. }
  320. case 2:
  321. if wireType != 0 {
  322. return fmt.Errorf("proto: wrong wireType = %d for field Nanos", wireType)
  323. }
  324. m.Nanos = 0
  325. for shift := uint(0); ; shift += 7 {
  326. if shift >= 64 {
  327. return ErrIntOverflowDuration
  328. }
  329. if iNdEx >= l {
  330. return io.ErrUnexpectedEOF
  331. }
  332. b := dAtA[iNdEx]
  333. iNdEx++
  334. m.Nanos |= (int32(b) & 0x7F) << shift
  335. if b < 0x80 {
  336. break
  337. }
  338. }
  339. default:
  340. iNdEx = preIndex
  341. skippy, err := skipDuration(dAtA[iNdEx:])
  342. if err != nil {
  343. return err
  344. }
  345. if skippy < 0 {
  346. return ErrInvalidLengthDuration
  347. }
  348. if (iNdEx + skippy) > l {
  349. return io.ErrUnexpectedEOF
  350. }
  351. iNdEx += skippy
  352. }
  353. }
  354. if iNdEx > l {
  355. return io.ErrUnexpectedEOF
  356. }
  357. return nil
  358. }
  359. func skipDuration(dAtA []byte) (n int, err error) {
  360. l := len(dAtA)
  361. iNdEx := 0
  362. for iNdEx < l {
  363. var wire uint64
  364. for shift := uint(0); ; shift += 7 {
  365. if shift >= 64 {
  366. return 0, ErrIntOverflowDuration
  367. }
  368. if iNdEx >= l {
  369. return 0, io.ErrUnexpectedEOF
  370. }
  371. b := dAtA[iNdEx]
  372. iNdEx++
  373. wire |= (uint64(b) & 0x7F) << shift
  374. if b < 0x80 {
  375. break
  376. }
  377. }
  378. wireType := int(wire & 0x7)
  379. switch wireType {
  380. case 0:
  381. for shift := uint(0); ; shift += 7 {
  382. if shift >= 64 {
  383. return 0, ErrIntOverflowDuration
  384. }
  385. if iNdEx >= l {
  386. return 0, io.ErrUnexpectedEOF
  387. }
  388. iNdEx++
  389. if dAtA[iNdEx-1] < 0x80 {
  390. break
  391. }
  392. }
  393. return iNdEx, nil
  394. case 1:
  395. iNdEx += 8
  396. return iNdEx, nil
  397. case 2:
  398. var length int
  399. for shift := uint(0); ; shift += 7 {
  400. if shift >= 64 {
  401. return 0, ErrIntOverflowDuration
  402. }
  403. if iNdEx >= l {
  404. return 0, io.ErrUnexpectedEOF
  405. }
  406. b := dAtA[iNdEx]
  407. iNdEx++
  408. length |= (int(b) & 0x7F) << shift
  409. if b < 0x80 {
  410. break
  411. }
  412. }
  413. iNdEx += length
  414. if length < 0 {
  415. return 0, ErrInvalidLengthDuration
  416. }
  417. return iNdEx, nil
  418. case 3:
  419. for {
  420. var innerWire uint64
  421. var start int = iNdEx
  422. for shift := uint(0); ; shift += 7 {
  423. if shift >= 64 {
  424. return 0, ErrIntOverflowDuration
  425. }
  426. if iNdEx >= l {
  427. return 0, io.ErrUnexpectedEOF
  428. }
  429. b := dAtA[iNdEx]
  430. iNdEx++
  431. innerWire |= (uint64(b) & 0x7F) << shift
  432. if b < 0x80 {
  433. break
  434. }
  435. }
  436. innerWireType := int(innerWire & 0x7)
  437. if innerWireType == 4 {
  438. break
  439. }
  440. next, err := skipDuration(dAtA[start:])
  441. if err != nil {
  442. return 0, err
  443. }
  444. iNdEx = start + next
  445. }
  446. return iNdEx, nil
  447. case 4:
  448. return iNdEx, nil
  449. case 5:
  450. iNdEx += 4
  451. return iNdEx, nil
  452. default:
  453. return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
  454. }
  455. }
  456. panic("unreachable")
  457. }
  458. var (
  459. ErrInvalidLengthDuration = fmt.Errorf("proto: negative length found during unmarshaling")
  460. ErrIntOverflowDuration = fmt.Errorf("proto: integer overflow")
  461. )
  462. func init() { proto.RegisterFile("duration.proto", fileDescriptorDuration) }
  463. var fileDescriptorDuration = []byte{
  464. // 203 bytes of a gzipped FileDescriptorProto
  465. 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4b, 0x29, 0x2d, 0x4a,
  466. 0x2c, 0xc9, 0xcc, 0xcf, 0xd3, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x4f, 0xcf, 0xcf, 0x4f,
  467. 0xcf, 0x49, 0x85, 0xf0, 0x92, 0x4a, 0xd3, 0x94, 0xac, 0xb8, 0x38, 0x5c, 0xa0, 0x4a, 0x84, 0x24,
  468. 0xb8, 0xd8, 0x8b, 0x53, 0x93, 0xf3, 0xf3, 0x52, 0x8a, 0x25, 0x18, 0x15, 0x18, 0x35, 0x98, 0x83,
  469. 0x60, 0x5c, 0x21, 0x11, 0x2e, 0xd6, 0xbc, 0xc4, 0xbc, 0xfc, 0x62, 0x09, 0x26, 0x05, 0x46, 0x0d,
  470. 0xd6, 0x20, 0x08, 0xc7, 0xa9, 0xfe, 0xc2, 0x43, 0x39, 0x86, 0x1b, 0x0f, 0xe5, 0x18, 0x3e, 0x3c,
  471. 0x94, 0x63, 0x5c, 0xf1, 0x48, 0x8e, 0xf1, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f,
  472. 0x3c, 0x92, 0x63, 0x7c, 0xf1, 0x48, 0x8e, 0xe1, 0xc3, 0x23, 0x39, 0xc6, 0x15, 0x8f, 0xe5, 0x18,
  473. 0xb9, 0x84, 0x93, 0xf3, 0x73, 0xf5, 0xd0, 0xac, 0x76, 0xe2, 0x85, 0x59, 0x1c, 0x00, 0x12, 0x09,
  474. 0x60, 0x8c, 0x62, 0x2d, 0xa9, 0x2c, 0x48, 0x2d, 0xfe, 0xc1, 0xc8, 0xb8, 0x88, 0x89, 0xd9, 0x3d,
  475. 0xc0, 0x69, 0x15, 0x93, 0x9c, 0x3b, 0x44, 0x4b, 0x00, 0x54, 0x8b, 0x5e, 0x78, 0x6a, 0x4e, 0x8e,
  476. 0x77, 0x5e, 0x7e, 0x79, 0x5e, 0x08, 0x48, 0x65, 0x12, 0x1b, 0xd8, 0x2c, 0x63, 0x40, 0x00, 0x00,
  477. 0x00, 0xff, 0xff, 0x9d, 0x5a, 0x25, 0xa5, 0xe6, 0x00, 0x00, 0x00,
  478. }