struct.pb.swift 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  1. // DO NOT EDIT.
  2. // swift-format-ignore-file
  3. // swiftlint:disable all
  4. //
  5. // Generated by the Swift generator plugin for the protocol buffer compiler.
  6. // Source: google/protobuf/struct.proto
  7. //
  8. // For information on using the generated types, please see the documentation:
  9. // https://github.com/apple/swift-protobuf/
  10. // Protocol Buffers - Google's data interchange format
  11. // Copyright 2008 Google Inc. All rights reserved.
  12. // https://developers.google.com/protocol-buffers/
  13. //
  14. // Redistribution and use in source and binary forms, with or without
  15. // modification, are permitted provided that the following conditions are
  16. // met:
  17. //
  18. // * Redistributions of source code must retain the above copyright
  19. // notice, this list of conditions and the following disclaimer.
  20. // * Redistributions in binary form must reproduce the above
  21. // copyright notice, this list of conditions and the following disclaimer
  22. // in the documentation and/or other materials provided with the
  23. // distribution.
  24. // * Neither the name of Google Inc. nor the names of its
  25. // contributors may be used to endorse or promote products derived from
  26. // this software without specific prior written permission.
  27. //
  28. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  29. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  30. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  31. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  32. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  33. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  34. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  35. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  36. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  37. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  38. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  39. // 'import SwiftProtobuf' suppressed, this proto file is meant to be bundled in the runtime.
  40. // If the compiler emits an error on this type, it is because this file
  41. // was generated by a version of the `protoc` Swift plug-in that is
  42. // incompatible with the version of SwiftProtobuf to which you are linking.
  43. // Please ensure that you are building against the same version of the API
  44. // that was used to generate this file.
  45. fileprivate struct _GeneratedWithProtocGenSwiftVersion: ProtobufAPIVersionCheck {
  46. struct _2: ProtobufAPIVersion_2 {}
  47. typealias Version = _2
  48. }
  49. /// `NullValue` is a singleton enumeration to represent the null value for the
  50. /// `Value` type union.
  51. ///
  52. /// The JSON representation for `NullValue` is JSON `null`.
  53. public enum Google_Protobuf_NullValue: Enum, Swift.CaseIterable {
  54. public typealias RawValue = Int
  55. /// Null value.
  56. case nullValue // = 0
  57. case UNRECOGNIZED(Int)
  58. public init() {
  59. self = .nullValue
  60. }
  61. public init?(rawValue: Int) {
  62. switch rawValue {
  63. case 0: self = .nullValue
  64. default: self = .UNRECOGNIZED(rawValue)
  65. }
  66. }
  67. public var rawValue: Int {
  68. switch self {
  69. case .nullValue: return 0
  70. case .UNRECOGNIZED(let i): return i
  71. }
  72. }
  73. // The compiler won't synthesize support with the UNRECOGNIZED case.
  74. public static let allCases: [Google_Protobuf_NullValue] = [
  75. .nullValue,
  76. ]
  77. }
  78. /// `Struct` represents a structured data value, consisting of fields
  79. /// which map to dynamically typed values. In some languages, `Struct`
  80. /// might be supported by a native representation. For example, in
  81. /// scripting languages like JS a struct is represented as an
  82. /// object. The details of that representation are described together
  83. /// with the proto support for the language.
  84. ///
  85. /// The JSON representation for `Struct` is JSON object.
  86. public struct Google_Protobuf_Struct: Sendable {
  87. // SwiftProtobuf.Message conformance is added in an extension below. See the
  88. // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  89. // methods supported on all messages.
  90. /// Unordered map of dynamically typed values.
  91. public var fields: Dictionary<String,Google_Protobuf_Value> = [:]
  92. public var unknownFields = UnknownStorage()
  93. public init() {}
  94. }
  95. /// `Value` represents a dynamically typed value which can be either
  96. /// null, a number, a string, a boolean, a recursive struct value, or a
  97. /// list of values. A producer of value is expected to set one of these
  98. /// variants. Absence of any variant indicates an error.
  99. ///
  100. /// The JSON representation for `Value` is JSON value.
  101. public struct Google_Protobuf_Value: Sendable {
  102. // SwiftProtobuf.Message conformance is added in an extension below. See the
  103. // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  104. // methods supported on all messages.
  105. /// The kind of value.
  106. public var kind: Google_Protobuf_Value.OneOf_Kind? = nil
  107. /// Represents a null value.
  108. public var nullValue: Google_Protobuf_NullValue {
  109. get {
  110. if case .nullValue(let v)? = kind {return v}
  111. return .nullValue
  112. }
  113. set {kind = .nullValue(newValue)}
  114. }
  115. /// Represents a double value.
  116. public var numberValue: Double {
  117. get {
  118. if case .numberValue(let v)? = kind {return v}
  119. return 0
  120. }
  121. set {kind = .numberValue(newValue)}
  122. }
  123. /// Represents a string value.
  124. public var stringValue: String {
  125. get {
  126. if case .stringValue(let v)? = kind {return v}
  127. return String()
  128. }
  129. set {kind = .stringValue(newValue)}
  130. }
  131. /// Represents a boolean value.
  132. public var boolValue: Bool {
  133. get {
  134. if case .boolValue(let v)? = kind {return v}
  135. return false
  136. }
  137. set {kind = .boolValue(newValue)}
  138. }
  139. /// Represents a structured value.
  140. public var structValue: Google_Protobuf_Struct {
  141. get {
  142. if case .structValue(let v)? = kind {return v}
  143. return Google_Protobuf_Struct()
  144. }
  145. set {kind = .structValue(newValue)}
  146. }
  147. /// Represents a repeated `Value`.
  148. public var listValue: Google_Protobuf_ListValue {
  149. get {
  150. if case .listValue(let v)? = kind {return v}
  151. return Google_Protobuf_ListValue()
  152. }
  153. set {kind = .listValue(newValue)}
  154. }
  155. public var unknownFields = UnknownStorage()
  156. /// The kind of value.
  157. public enum OneOf_Kind: Equatable, Sendable {
  158. /// Represents a null value.
  159. case nullValue(Google_Protobuf_NullValue)
  160. /// Represents a double value.
  161. case numberValue(Double)
  162. /// Represents a string value.
  163. case stringValue(String)
  164. /// Represents a boolean value.
  165. case boolValue(Bool)
  166. /// Represents a structured value.
  167. case structValue(Google_Protobuf_Struct)
  168. /// Represents a repeated `Value`.
  169. case listValue(Google_Protobuf_ListValue)
  170. }
  171. public init() {}
  172. }
  173. /// `ListValue` is a wrapper around a repeated field of values.
  174. ///
  175. /// The JSON representation for `ListValue` is JSON array.
  176. public struct Google_Protobuf_ListValue: Sendable {
  177. // SwiftProtobuf.Message conformance is added in an extension below. See the
  178. // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  179. // methods supported on all messages.
  180. /// Repeated field of dynamically typed values.
  181. public var values: [Google_Protobuf_Value] = []
  182. public var unknownFields = UnknownStorage()
  183. public init() {}
  184. }
  185. // MARK: - Code below here is support for the SwiftProtobuf runtime.
  186. fileprivate let _protobuf_package = "google.protobuf"
  187. extension Google_Protobuf_NullValue: _ProtoNameProviding {
  188. public static let _protobuf_nameMap: _NameMap = [
  189. 0: .same(proto: "NULL_VALUE"),
  190. ]
  191. }
  192. extension Google_Protobuf_Struct: Message, _MessageImplementationBase, _ProtoNameProviding {
  193. public static let protoMessageName: String = _protobuf_package + ".Struct"
  194. public static let _protobuf_nameMap: _NameMap = [
  195. 1: .same(proto: "fields"),
  196. ]
  197. public mutating func decodeMessage<D: Decoder>(decoder: inout D) throws {
  198. while let fieldNumber = try decoder.nextFieldNumber() {
  199. // The use of inline closures is to circumvent an issue where the compiler
  200. // allocates stack space for every case branch when no optimizations are
  201. // enabled. https://github.com/apple/swift-protobuf/issues/1034
  202. switch fieldNumber {
  203. case 1: try { try decoder.decodeMapField(fieldType: _ProtobufMessageMap<ProtobufString,Google_Protobuf_Value>.self, value: &self.fields) }()
  204. default: break
  205. }
  206. }
  207. }
  208. public func traverse<V: Visitor>(visitor: inout V) throws {
  209. if !self.fields.isEmpty {
  210. try visitor.visitMapField(fieldType: _ProtobufMessageMap<ProtobufString,Google_Protobuf_Value>.self, value: self.fields, fieldNumber: 1)
  211. }
  212. try unknownFields.traverse(visitor: &visitor)
  213. }
  214. public static func ==(lhs: Google_Protobuf_Struct, rhs: Google_Protobuf_Struct) -> Bool {
  215. if lhs.fields != rhs.fields {return false}
  216. if lhs.unknownFields != rhs.unknownFields {return false}
  217. return true
  218. }
  219. }
  220. extension Google_Protobuf_Value: Message, _MessageImplementationBase, _ProtoNameProviding {
  221. public static let protoMessageName: String = _protobuf_package + ".Value"
  222. public static let _protobuf_nameMap: _NameMap = [
  223. 1: .standard(proto: "null_value"),
  224. 2: .standard(proto: "number_value"),
  225. 3: .standard(proto: "string_value"),
  226. 4: .standard(proto: "bool_value"),
  227. 5: .standard(proto: "struct_value"),
  228. 6: .standard(proto: "list_value"),
  229. ]
  230. public mutating func decodeMessage<D: Decoder>(decoder: inout D) throws {
  231. while let fieldNumber = try decoder.nextFieldNumber() {
  232. // The use of inline closures is to circumvent an issue where the compiler
  233. // allocates stack space for every case branch when no optimizations are
  234. // enabled. https://github.com/apple/swift-protobuf/issues/1034
  235. switch fieldNumber {
  236. case 1: try {
  237. var v: Google_Protobuf_NullValue?
  238. try decoder.decodeSingularEnumField(value: &v)
  239. if let v = v {
  240. if self.kind != nil {try decoder.handleConflictingOneOf()}
  241. self.kind = .nullValue(v)
  242. }
  243. }()
  244. case 2: try {
  245. var v: Double?
  246. try decoder.decodeSingularDoubleField(value: &v)
  247. if let v = v {
  248. if self.kind != nil {try decoder.handleConflictingOneOf()}
  249. self.kind = .numberValue(v)
  250. }
  251. }()
  252. case 3: try {
  253. var v: String?
  254. try decoder.decodeSingularStringField(value: &v)
  255. if let v = v {
  256. if self.kind != nil {try decoder.handleConflictingOneOf()}
  257. self.kind = .stringValue(v)
  258. }
  259. }()
  260. case 4: try {
  261. var v: Bool?
  262. try decoder.decodeSingularBoolField(value: &v)
  263. if let v = v {
  264. if self.kind != nil {try decoder.handleConflictingOneOf()}
  265. self.kind = .boolValue(v)
  266. }
  267. }()
  268. case 5: try {
  269. var v: Google_Protobuf_Struct?
  270. var hadOneofValue = false
  271. if let current = self.kind {
  272. hadOneofValue = true
  273. if case .structValue(let m) = current {v = m}
  274. }
  275. try decoder.decodeSingularMessageField(value: &v)
  276. if let v = v {
  277. if hadOneofValue {try decoder.handleConflictingOneOf()}
  278. self.kind = .structValue(v)
  279. }
  280. }()
  281. case 6: try {
  282. var v: Google_Protobuf_ListValue?
  283. var hadOneofValue = false
  284. if let current = self.kind {
  285. hadOneofValue = true
  286. if case .listValue(let m) = current {v = m}
  287. }
  288. try decoder.decodeSingularMessageField(value: &v)
  289. if let v = v {
  290. if hadOneofValue {try decoder.handleConflictingOneOf()}
  291. self.kind = .listValue(v)
  292. }
  293. }()
  294. default: break
  295. }
  296. }
  297. }
  298. public func traverse<V: Visitor>(visitor: inout V) throws {
  299. // The use of inline closures is to circumvent an issue where the compiler
  300. // allocates stack space for every if/case branch local when no optimizations
  301. // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
  302. // https://github.com/apple/swift-protobuf/issues/1182
  303. switch self.kind {
  304. case .nullValue?: try {
  305. guard case .nullValue(let v)? = self.kind else { preconditionFailure() }
  306. try visitor.visitSingularEnumField(value: v, fieldNumber: 1)
  307. }()
  308. case .numberValue?: try {
  309. guard case .numberValue(let v)? = self.kind else { preconditionFailure() }
  310. try visitor.visitSingularDoubleField(value: v, fieldNumber: 2)
  311. }()
  312. case .stringValue?: try {
  313. guard case .stringValue(let v)? = self.kind else { preconditionFailure() }
  314. try visitor.visitSingularStringField(value: v, fieldNumber: 3)
  315. }()
  316. case .boolValue?: try {
  317. guard case .boolValue(let v)? = self.kind else { preconditionFailure() }
  318. try visitor.visitSingularBoolField(value: v, fieldNumber: 4)
  319. }()
  320. case .structValue?: try {
  321. guard case .structValue(let v)? = self.kind else { preconditionFailure() }
  322. try visitor.visitSingularMessageField(value: v, fieldNumber: 5)
  323. }()
  324. case .listValue?: try {
  325. guard case .listValue(let v)? = self.kind else { preconditionFailure() }
  326. try visitor.visitSingularMessageField(value: v, fieldNumber: 6)
  327. }()
  328. case nil: break
  329. }
  330. try unknownFields.traverse(visitor: &visitor)
  331. }
  332. public static func ==(lhs: Google_Protobuf_Value, rhs: Google_Protobuf_Value) -> Bool {
  333. if lhs.kind != rhs.kind {return false}
  334. if lhs.unknownFields != rhs.unknownFields {return false}
  335. return true
  336. }
  337. }
  338. extension Google_Protobuf_ListValue: Message, _MessageImplementationBase, _ProtoNameProviding {
  339. public static let protoMessageName: String = _protobuf_package + ".ListValue"
  340. public static let _protobuf_nameMap: _NameMap = [
  341. 1: .same(proto: "values"),
  342. ]
  343. public mutating func decodeMessage<D: Decoder>(decoder: inout D) throws {
  344. while let fieldNumber = try decoder.nextFieldNumber() {
  345. // The use of inline closures is to circumvent an issue where the compiler
  346. // allocates stack space for every case branch when no optimizations are
  347. // enabled. https://github.com/apple/swift-protobuf/issues/1034
  348. switch fieldNumber {
  349. case 1: try { try decoder.decodeRepeatedMessageField(value: &self.values) }()
  350. default: break
  351. }
  352. }
  353. }
  354. public func traverse<V: Visitor>(visitor: inout V) throws {
  355. if !self.values.isEmpty {
  356. try visitor.visitRepeatedMessageField(value: self.values, fieldNumber: 1)
  357. }
  358. try unknownFields.traverse(visitor: &visitor)
  359. }
  360. public static func ==(lhs: Google_Protobuf_ListValue, rhs: Google_Protobuf_ListValue) -> Bool {
  361. if lhs.values != rhs.values {return false}
  362. if lhs.unknownFields != rhs.unknownFields {return false}
  363. return true
  364. }
  365. }