duration.pb.swift 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * DO NOT EDIT.
  3. *
  4. * Generated by the protocol buffer compiler.
  5. * Source: google/protobuf/duration.proto
  6. *
  7. */
  8. /// A Duration represents a signed, fixed-length span of time represented
  9. /// as a count of seconds and fractions of seconds at nanosecond
  10. /// resolution. It is independent of any calendar and concepts like "day"
  11. /// or "month". It is related to Timestamp in that the difference between
  12. /// two Timestamp values is a Duration and it can be added or subtracted
  13. /// from a Timestamp. Range is approximately +-10,000 years.
  14. ///
  15. /// Example 1: Compute Duration from two Timestamps in pseudo code.
  16. ///
  17. /// Timestamp start = ...;
  18. /// Timestamp end = ...;
  19. /// Duration duration = ...;
  20. ///
  21. /// duration.seconds = end.seconds - start.seconds;
  22. /// duration.nanos = end.nanos - start.nanos;
  23. ///
  24. /// if (duration.seconds < 0 && duration.nanos > 0) {
  25. /// duration.seconds += 1;
  26. /// duration.nanos -= 1000000000;
  27. /// } else if (durations.seconds > 0 && duration.nanos < 0) {
  28. /// duration.seconds -= 1;
  29. /// duration.nanos += 1000000000;
  30. /// }
  31. ///
  32. /// Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
  33. ///
  34. /// Timestamp start = ...;
  35. /// Duration duration = ...;
  36. /// Timestamp end = ...;
  37. ///
  38. /// end.seconds = start.seconds + duration.seconds;
  39. /// end.nanos = start.nanos + duration.nanos;
  40. ///
  41. /// if (end.nanos < 0) {
  42. /// end.seconds -= 1;
  43. /// end.nanos += 1000000000;
  44. /// } else if (end.nanos >= 1000000000) {
  45. /// end.seconds += 1;
  46. /// end.nanos -= 1000000000;
  47. /// }
  48. public struct Google_Protobuf_Duration: ProtobufGeneratedMessage {
  49. public var swiftClassName: String {return "Google_Protobuf_Duration"}
  50. public var protoMessageName: String {return "Duration"}
  51. public var protoPackageName: String {return "google.protobuf"}
  52. public var jsonFieldNames: [String: Int] {return [
  53. "seconds": 1,
  54. "nanos": 2,
  55. ]}
  56. public var protoFieldNames: [String: Int] {return [
  57. "seconds": 1,
  58. "nanos": 2,
  59. ]}
  60. /// Signed seconds of the span of time. Must be from -315,576,000,000
  61. /// to +315,576,000,000 inclusive.
  62. public var seconds: Int64 = 0
  63. /// Signed fractions of a second at nanosecond resolution of the span
  64. /// of time. Durations less than one second are represented with a 0
  65. /// `seconds` field and a positive or negative `nanos` field. For durations
  66. /// of one second or more, a non-zero value for the `nanos` field must be
  67. /// of the same sign as the `seconds` field. Must be from -999,999,999
  68. /// to +999,999,999 inclusive.
  69. public var nanos: Int32 = 0
  70. public init() {}
  71. public init(seconds: Int64? = nil,
  72. nanos: Int32? = nil)
  73. {
  74. if let v = seconds {
  75. self.seconds = v
  76. }
  77. if let v = nanos {
  78. self.nanos = v
  79. }
  80. }
  81. public mutating func _protoc_generated_decodeField(setter: inout ProtobufFieldDecoder, protoFieldNumber: Int) throws -> Bool {
  82. let handled: Bool
  83. switch protoFieldNumber {
  84. case 1: handled = try setter.decodeSingularField(fieldType: ProtobufInt64.self, value: &seconds)
  85. case 2: handled = try setter.decodeSingularField(fieldType: ProtobufInt32.self, value: &nanos)
  86. default:
  87. handled = false
  88. }
  89. return handled
  90. }
  91. public func _protoc_generated_traverse(visitor: inout ProtobufVisitor) throws {
  92. if seconds != 0 {
  93. try visitor.visitSingularField(fieldType: ProtobufInt64.self, value: seconds, protoFieldNumber: 1, protoFieldName: "seconds", jsonFieldName: "seconds", swiftFieldName: "seconds")
  94. }
  95. if nanos != 0 {
  96. try visitor.visitSingularField(fieldType: ProtobufInt32.self, value: nanos, protoFieldNumber: 2, protoFieldName: "nanos", jsonFieldName: "nanos", swiftFieldName: "nanos")
  97. }
  98. }
  99. public var _protoc_generated_isEmpty: Bool {
  100. if seconds != 0 {return false}
  101. if nanos != 0 {return false}
  102. return true
  103. }
  104. public func _protoc_generated_isEqualTo(other: Google_Protobuf_Duration) -> Bool {
  105. if seconds != other.seconds {return false}
  106. if nanos != other.nanos {return false}
  107. return true
  108. }
  109. }