KitchenSinkKeys.swift 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. import Foundation
  2. import FirebaseDataConnect
  3. public struct LargeIntTypeKey {
  4. public private(set) var id: UUID
  5. enum CodingKeys: String, CodingKey {
  6. case id
  7. }
  8. }
  9. @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
  10. extension LargeIntTypeKey: Codable {
  11. public init(from decoder: any Decoder) throws {
  12. var container = try decoder.container(keyedBy: CodingKeys.self)
  13. let codecHelper = CodecHelper<CodingKeys>()
  14. id = try codecHelper.decode(UUID.self, forKey: .id, container: &container)
  15. }
  16. public func encode(to encoder: Encoder) throws {
  17. var container = encoder.container(keyedBy: CodingKeys.self)
  18. let codecHelper = CodecHelper<CodingKeys>()
  19. try codecHelper.encode(id, forKey: .id, container: &container)
  20. }
  21. }
  22. extension LargeIntTypeKey: Equatable {
  23. public static func == (lhs: LargeIntTypeKey, rhs: LargeIntTypeKey) -> Bool {
  24. if lhs.id != rhs.id {
  25. return false
  26. }
  27. return true
  28. }
  29. }
  30. extension LargeIntTypeKey: Hashable {
  31. public func hash(into hasher: inout Hasher) {
  32. hasher.combine(id)
  33. }
  34. }
  35. public struct LocalDateTypeKey {
  36. public private(set) var id: UUID
  37. enum CodingKeys: String, CodingKey {
  38. case id
  39. }
  40. }
  41. @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
  42. extension LocalDateTypeKey: Codable {
  43. public init(from decoder: any Decoder) throws {
  44. var container = try decoder.container(keyedBy: CodingKeys.self)
  45. let codecHelper = CodecHelper<CodingKeys>()
  46. id = try codecHelper.decode(UUID.self, forKey: .id, container: &container)
  47. }
  48. public func encode(to encoder: Encoder) throws {
  49. var container = encoder.container(keyedBy: CodingKeys.self)
  50. let codecHelper = CodecHelper<CodingKeys>()
  51. try codecHelper.encode(id, forKey: .id, container: &container)
  52. }
  53. }
  54. extension LocalDateTypeKey: Equatable {
  55. public static func == (lhs: LocalDateTypeKey, rhs: LocalDateTypeKey) -> Bool {
  56. if lhs.id != rhs.id {
  57. return false
  58. }
  59. return true
  60. }
  61. }
  62. extension LocalDateTypeKey: Hashable {
  63. public func hash(into hasher: inout Hasher) {
  64. hasher.combine(id)
  65. }
  66. }
  67. public struct ScalarBoundaryKey {
  68. public private(set) var id: UUID
  69. enum CodingKeys: String, CodingKey {
  70. case id
  71. }
  72. }
  73. @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
  74. extension ScalarBoundaryKey: Codable {
  75. public init(from decoder: any Decoder) throws {
  76. var container = try decoder.container(keyedBy: CodingKeys.self)
  77. let codecHelper = CodecHelper<CodingKeys>()
  78. id = try codecHelper.decode(UUID.self, forKey: .id, container: &container)
  79. }
  80. public func encode(to encoder: Encoder) throws {
  81. var container = encoder.container(keyedBy: CodingKeys.self)
  82. let codecHelper = CodecHelper<CodingKeys>()
  83. try codecHelper.encode(id, forKey: .id, container: &container)
  84. }
  85. }
  86. extension ScalarBoundaryKey: Equatable {
  87. public static func == (lhs: ScalarBoundaryKey, rhs: ScalarBoundaryKey) -> Bool {
  88. if lhs.id != rhs.id {
  89. return false
  90. }
  91. return true
  92. }
  93. }
  94. extension ScalarBoundaryKey: Hashable {
  95. public func hash(into hasher: inout Hasher) {
  96. hasher.combine(id)
  97. }
  98. }
  99. public struct StandardScalarsKey {
  100. public private(set) var id: UUID
  101. enum CodingKeys: String, CodingKey {
  102. case id
  103. }
  104. }
  105. @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
  106. extension StandardScalarsKey: Codable {
  107. public init(from decoder: any Decoder) throws {
  108. var container = try decoder.container(keyedBy: CodingKeys.self)
  109. let codecHelper = CodecHelper<CodingKeys>()
  110. id = try codecHelper.decode(UUID.self, forKey: .id, container: &container)
  111. }
  112. public func encode(to encoder: Encoder) throws {
  113. var container = encoder.container(keyedBy: CodingKeys.self)
  114. let codecHelper = CodecHelper<CodingKeys>()
  115. try codecHelper.encode(id, forKey: .id, container: &container)
  116. }
  117. }
  118. extension StandardScalarsKey: Equatable {
  119. public static func == (lhs: StandardScalarsKey, rhs: StandardScalarsKey) -> Bool {
  120. if lhs.id != rhs.id {
  121. return false
  122. }
  123. return true
  124. }
  125. }
  126. extension StandardScalarsKey: Hashable {
  127. public func hash(into hasher: inout Hasher) {
  128. hasher.combine(id)
  129. }
  130. }
  131. public struct TestAutoIdKey {
  132. public private(set) var id: UUID
  133. enum CodingKeys: String, CodingKey {
  134. case id
  135. }
  136. }
  137. @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
  138. extension TestAutoIdKey: Codable {
  139. public init(from decoder: any Decoder) throws {
  140. var container = try decoder.container(keyedBy: CodingKeys.self)
  141. let codecHelper = CodecHelper<CodingKeys>()
  142. id = try codecHelper.decode(UUID.self, forKey: .id, container: &container)
  143. }
  144. public func encode(to encoder: Encoder) throws {
  145. var container = encoder.container(keyedBy: CodingKeys.self)
  146. let codecHelper = CodecHelper<CodingKeys>()
  147. try codecHelper.encode(id, forKey: .id, container: &container)
  148. }
  149. }
  150. extension TestAutoIdKey: Equatable {
  151. public static func == (lhs: TestAutoIdKey, rhs: TestAutoIdKey) -> Bool {
  152. if lhs.id != rhs.id {
  153. return false
  154. }
  155. return true
  156. }
  157. }
  158. extension TestAutoIdKey: Hashable {
  159. public func hash(into hasher: inout Hasher) {
  160. hasher.combine(id)
  161. }
  162. }
  163. public struct TestIdKey {
  164. public private(set) var id: UUID
  165. enum CodingKeys: String, CodingKey {
  166. case id
  167. }
  168. }
  169. @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
  170. extension TestIdKey: Codable {
  171. public init(from decoder: any Decoder) throws {
  172. var container = try decoder.container(keyedBy: CodingKeys.self)
  173. let codecHelper = CodecHelper<CodingKeys>()
  174. id = try codecHelper.decode(UUID.self, forKey: .id, container: &container)
  175. }
  176. public func encode(to encoder: Encoder) throws {
  177. var container = encoder.container(keyedBy: CodingKeys.self)
  178. let codecHelper = CodecHelper<CodingKeys>()
  179. try codecHelper.encode(id, forKey: .id, container: &container)
  180. }
  181. }
  182. extension TestIdKey: Equatable {
  183. public static func == (lhs: TestIdKey, rhs: TestIdKey) -> Bool {
  184. if lhs.id != rhs.id {
  185. return false
  186. }
  187. return true
  188. }
  189. }
  190. extension TestIdKey: Hashable {
  191. public func hash(into hasher: inout Hasher) {
  192. hasher.combine(id)
  193. }
  194. }