control.pb.swift 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. // DO NOT EDIT.
  2. // swift-format-ignore-file
  3. //
  4. // Generated by the Swift generator plugin for the protocol buffer compiler.
  5. // Source: control.proto
  6. //
  7. // For information on using the generated types, please see the documentation:
  8. // https://github.com/apple/swift-protobuf/
  9. //
  10. // Copyright 2024, gRPC Authors All rights reserved.
  11. //
  12. // Licensed under the Apache License, Version 2.0 (the "License");
  13. // you may not use this file except in compliance with the License.
  14. // You may obtain a copy of the License at
  15. //
  16. // http://www.apache.org/licenses/LICENSE-2.0
  17. //
  18. // Unless required by applicable law or agreed to in writing, software
  19. // distributed under the License is distributed on an "AS IS" BASIS,
  20. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  21. // See the License for the specific language governing permissions and
  22. // limitations under the License.
  23. import Foundation
  24. import SwiftProtobuf
  25. // If the compiler emits an error on this type, it is because this file
  26. // was generated by a version of the `protoc` Swift plug-in that is
  27. // incompatible with the version of SwiftProtobuf to which you are linking.
  28. // Please ensure that you are building against the same version of the API
  29. // that was used to generate this file.
  30. fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck {
  31. struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {}
  32. typealias Version = _2
  33. }
  34. enum StatusCode: SwiftProtobuf.Enum, Swift.CaseIterable {
  35. typealias RawValue = Int
  36. case ok // = 0
  37. case cancelled // = 1
  38. case unknown // = 2
  39. case invalidArgument // = 3
  40. case deadlineExceeded // = 4
  41. case notFound // = 5
  42. case alreadyExists // = 6
  43. case permissionDenied // = 7
  44. case resourceExhausted // = 8
  45. case failedPrecondition // = 9
  46. case aborted // = 10
  47. case outOfRange // = 11
  48. case unimplemented // = 12
  49. case `internal` // = 13
  50. case unavailable // = 14
  51. case dataLoss // = 15
  52. case unauthenticated // = 16
  53. case UNRECOGNIZED(Int)
  54. init() {
  55. self = .ok
  56. }
  57. init?(rawValue: Int) {
  58. switch rawValue {
  59. case 0: self = .ok
  60. case 1: self = .cancelled
  61. case 2: self = .unknown
  62. case 3: self = .invalidArgument
  63. case 4: self = .deadlineExceeded
  64. case 5: self = .notFound
  65. case 6: self = .alreadyExists
  66. case 7: self = .permissionDenied
  67. case 8: self = .resourceExhausted
  68. case 9: self = .failedPrecondition
  69. case 10: self = .aborted
  70. case 11: self = .outOfRange
  71. case 12: self = .unimplemented
  72. case 13: self = .internal
  73. case 14: self = .unavailable
  74. case 15: self = .dataLoss
  75. case 16: self = .unauthenticated
  76. default: self = .UNRECOGNIZED(rawValue)
  77. }
  78. }
  79. var rawValue: Int {
  80. switch self {
  81. case .ok: return 0
  82. case .cancelled: return 1
  83. case .unknown: return 2
  84. case .invalidArgument: return 3
  85. case .deadlineExceeded: return 4
  86. case .notFound: return 5
  87. case .alreadyExists: return 6
  88. case .permissionDenied: return 7
  89. case .resourceExhausted: return 8
  90. case .failedPrecondition: return 9
  91. case .aborted: return 10
  92. case .outOfRange: return 11
  93. case .unimplemented: return 12
  94. case .internal: return 13
  95. case .unavailable: return 14
  96. case .dataLoss: return 15
  97. case .unauthenticated: return 16
  98. case .UNRECOGNIZED(let i): return i
  99. }
  100. }
  101. // The compiler won't synthesize support with the UNRECOGNIZED case.
  102. static let allCases: [StatusCode] = [
  103. .ok,
  104. .cancelled,
  105. .unknown,
  106. .invalidArgument,
  107. .deadlineExceeded,
  108. .notFound,
  109. .alreadyExists,
  110. .permissionDenied,
  111. .resourceExhausted,
  112. .failedPrecondition,
  113. .aborted,
  114. .outOfRange,
  115. .unimplemented,
  116. .internal,
  117. .unavailable,
  118. .dataLoss,
  119. .unauthenticated,
  120. ]
  121. }
  122. struct ControlInput: Sendable {
  123. // SwiftProtobuf.Message conformance is added in an extension below. See the
  124. // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  125. // methods supported on all messages.
  126. /// Whether metadata should be echo'd back in the initial metadata.
  127. ///
  128. /// Ignored if the initial metadata has already been sent back to the
  129. /// client.
  130. ///
  131. /// Each header field name in the request headers will be prefixed with
  132. /// "echo-". For example the header field name "foo" will be returned
  133. /// as "echo-foo. Note that semicolons aren't valid in HTTP header field
  134. /// names (apart from pseudo headers). As such all semicolons should be
  135. /// removed (":path" should become "echo-path").
  136. var echoMetadataInHeaders: Bool = false
  137. /// Parameters for response messages.
  138. var messageParams: PayloadParameters {
  139. get {return _messageParams ?? PayloadParameters()}
  140. set {_messageParams = newValue}
  141. }
  142. /// Returns true if `messageParams` has been explicitly set.
  143. var hasMessageParams: Bool {return self._messageParams != nil}
  144. /// Clears the value of `messageParams`. Subsequent reads from it will return its default value.
  145. mutating func clearMessageParams() {self._messageParams = nil}
  146. /// The number of response messages.
  147. var numberOfMessages: Int32 = 0
  148. /// The status code and message to use at the end of the RPC.
  149. ///
  150. /// If this is set then the RPC will be ended after `number_of_messages`
  151. /// messages have been sent back to the client.
  152. var status: RPCStatus {
  153. get {return _status ?? RPCStatus()}
  154. set {_status = newValue}
  155. }
  156. /// Returns true if `status` has been explicitly set.
  157. var hasStatus: Bool {return self._status != nil}
  158. /// Clears the value of `status`. Subsequent reads from it will return its default value.
  159. mutating func clearStatus() {self._status = nil}
  160. /// Whether the response should be trailers only.
  161. ///
  162. /// Ignored unless it's set on the first message on the stream. When set
  163. /// the RPC will be completed with a trailers-only response using the
  164. /// status code and message from 'status'. The request metadata will be
  165. /// included if 'echo_metadata_in_trailers' is set.
  166. ///
  167. /// If this is set then 'number_of_messages', 'message_params', and
  168. /// 'echo_metadata_in_headers' are ignored.
  169. var isTrailersOnly: Bool = false
  170. /// Whether metadata should be echo'd back in the trailing metadata.
  171. ///
  172. /// Ignored unless 'status' is set.
  173. ///
  174. /// Each header field name in the request headers will be prefixed with
  175. /// "echo-". For example the header field name "foo" will be returned
  176. /// as "echo-foo. Note that semicolons aren't valid in HTTP header field
  177. /// names (apart from pseudo headers). As such all semicolons should be
  178. /// removed (":path" should become "echo-path").
  179. var echoMetadataInTrailers: Bool = false
  180. var unknownFields = SwiftProtobuf.UnknownStorage()
  181. init() {}
  182. fileprivate var _messageParams: PayloadParameters? = nil
  183. fileprivate var _status: RPCStatus? = nil
  184. }
  185. struct RPCStatus: Sendable {
  186. // SwiftProtobuf.Message conformance is added in an extension below. See the
  187. // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  188. // methods supported on all messages.
  189. /// Status code indicating the outcome of the RPC.
  190. var code: StatusCode = .ok
  191. /// The message to include with the 'code' at the end of the RPC.
  192. var message: String = String()
  193. var unknownFields = SwiftProtobuf.UnknownStorage()
  194. init() {}
  195. }
  196. struct PayloadParameters: Sendable {
  197. // SwiftProtobuf.Message conformance is added in an extension below. See the
  198. // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  199. // methods supported on all messages.
  200. /// The number of bytes to put into the output payload.
  201. var size: Int32 = 0
  202. /// The content to use in the payload. The value is truncated to an octet.
  203. var content: UInt32 = 0
  204. var unknownFields = SwiftProtobuf.UnknownStorage()
  205. init() {}
  206. }
  207. struct ControlOutput: @unchecked Sendable {
  208. // SwiftProtobuf.Message conformance is added in an extension below. See the
  209. // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  210. // methods supported on all messages.
  211. var payload: Data = Data()
  212. var unknownFields = SwiftProtobuf.UnknownStorage()
  213. init() {}
  214. }
  215. // MARK: - Code below here is support for the SwiftProtobuf runtime.
  216. extension StatusCode: SwiftProtobuf._ProtoNameProviding {
  217. static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
  218. 0: .same(proto: "OK"),
  219. 1: .same(proto: "CANCELLED"),
  220. 2: .same(proto: "UNKNOWN"),
  221. 3: .same(proto: "INVALID_ARGUMENT"),
  222. 4: .same(proto: "DEADLINE_EXCEEDED"),
  223. 5: .same(proto: "NOT_FOUND"),
  224. 6: .same(proto: "ALREADY_EXISTS"),
  225. 7: .same(proto: "PERMISSION_DENIED"),
  226. 8: .same(proto: "RESOURCE_EXHAUSTED"),
  227. 9: .same(proto: "FAILED_PRECONDITION"),
  228. 10: .same(proto: "ABORTED"),
  229. 11: .same(proto: "OUT_OF_RANGE"),
  230. 12: .same(proto: "UNIMPLEMENTED"),
  231. 13: .same(proto: "INTERNAL"),
  232. 14: .same(proto: "UNAVAILABLE"),
  233. 15: .same(proto: "DATA_LOSS"),
  234. 16: .same(proto: "UNAUTHENTICATED"),
  235. ]
  236. }
  237. extension ControlInput: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  238. static let protoMessageName: String = "ControlInput"
  239. static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
  240. 1: .standard(proto: "echo_metadata_in_headers"),
  241. 2: .standard(proto: "message_params"),
  242. 3: .standard(proto: "number_of_messages"),
  243. 5: .same(proto: "status"),
  244. 6: .standard(proto: "is_trailers_only"),
  245. 4: .standard(proto: "echo_metadata_in_trailers"),
  246. ]
  247. mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
  248. while let fieldNumber = try decoder.nextFieldNumber() {
  249. // The use of inline closures is to circumvent an issue where the compiler
  250. // allocates stack space for every case branch when no optimizations are
  251. // enabled. https://github.com/apple/swift-protobuf/issues/1034
  252. switch fieldNumber {
  253. case 1: try { try decoder.decodeSingularBoolField(value: &self.echoMetadataInHeaders) }()
  254. case 2: try { try decoder.decodeSingularMessageField(value: &self._messageParams) }()
  255. case 3: try { try decoder.decodeSingularInt32Field(value: &self.numberOfMessages) }()
  256. case 4: try { try decoder.decodeSingularBoolField(value: &self.echoMetadataInTrailers) }()
  257. case 5: try { try decoder.decodeSingularMessageField(value: &self._status) }()
  258. case 6: try { try decoder.decodeSingularBoolField(value: &self.isTrailersOnly) }()
  259. default: break
  260. }
  261. }
  262. }
  263. func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
  264. // The use of inline closures is to circumvent an issue where the compiler
  265. // allocates stack space for every if/case branch local when no optimizations
  266. // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
  267. // https://github.com/apple/swift-protobuf/issues/1182
  268. if self.echoMetadataInHeaders != false {
  269. try visitor.visitSingularBoolField(value: self.echoMetadataInHeaders, fieldNumber: 1)
  270. }
  271. try { if let v = self._messageParams {
  272. try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
  273. } }()
  274. if self.numberOfMessages != 0 {
  275. try visitor.visitSingularInt32Field(value: self.numberOfMessages, fieldNumber: 3)
  276. }
  277. if self.echoMetadataInTrailers != false {
  278. try visitor.visitSingularBoolField(value: self.echoMetadataInTrailers, fieldNumber: 4)
  279. }
  280. try { if let v = self._status {
  281. try visitor.visitSingularMessageField(value: v, fieldNumber: 5)
  282. } }()
  283. if self.isTrailersOnly != false {
  284. try visitor.visitSingularBoolField(value: self.isTrailersOnly, fieldNumber: 6)
  285. }
  286. try unknownFields.traverse(visitor: &visitor)
  287. }
  288. static func ==(lhs: ControlInput, rhs: ControlInput) -> Bool {
  289. if lhs.echoMetadataInHeaders != rhs.echoMetadataInHeaders {return false}
  290. if lhs._messageParams != rhs._messageParams {return false}
  291. if lhs.numberOfMessages != rhs.numberOfMessages {return false}
  292. if lhs._status != rhs._status {return false}
  293. if lhs.isTrailersOnly != rhs.isTrailersOnly {return false}
  294. if lhs.echoMetadataInTrailers != rhs.echoMetadataInTrailers {return false}
  295. if lhs.unknownFields != rhs.unknownFields {return false}
  296. return true
  297. }
  298. }
  299. extension RPCStatus: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  300. static let protoMessageName: String = "RPCStatus"
  301. static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
  302. 1: .same(proto: "code"),
  303. 2: .same(proto: "message"),
  304. ]
  305. mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
  306. while let fieldNumber = try decoder.nextFieldNumber() {
  307. // The use of inline closures is to circumvent an issue where the compiler
  308. // allocates stack space for every case branch when no optimizations are
  309. // enabled. https://github.com/apple/swift-protobuf/issues/1034
  310. switch fieldNumber {
  311. case 1: try { try decoder.decodeSingularEnumField(value: &self.code) }()
  312. case 2: try { try decoder.decodeSingularStringField(value: &self.message) }()
  313. default: break
  314. }
  315. }
  316. }
  317. func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
  318. if self.code != .ok {
  319. try visitor.visitSingularEnumField(value: self.code, fieldNumber: 1)
  320. }
  321. if !self.message.isEmpty {
  322. try visitor.visitSingularStringField(value: self.message, fieldNumber: 2)
  323. }
  324. try unknownFields.traverse(visitor: &visitor)
  325. }
  326. static func ==(lhs: RPCStatus, rhs: RPCStatus) -> Bool {
  327. if lhs.code != rhs.code {return false}
  328. if lhs.message != rhs.message {return false}
  329. if lhs.unknownFields != rhs.unknownFields {return false}
  330. return true
  331. }
  332. }
  333. extension PayloadParameters: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  334. static let protoMessageName: String = "PayloadParameters"
  335. static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
  336. 1: .same(proto: "size"),
  337. 2: .same(proto: "content"),
  338. ]
  339. mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
  340. while let fieldNumber = try decoder.nextFieldNumber() {
  341. // The use of inline closures is to circumvent an issue where the compiler
  342. // allocates stack space for every case branch when no optimizations are
  343. // enabled. https://github.com/apple/swift-protobuf/issues/1034
  344. switch fieldNumber {
  345. case 1: try { try decoder.decodeSingularInt32Field(value: &self.size) }()
  346. case 2: try { try decoder.decodeSingularUInt32Field(value: &self.content) }()
  347. default: break
  348. }
  349. }
  350. }
  351. func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
  352. if self.size != 0 {
  353. try visitor.visitSingularInt32Field(value: self.size, fieldNumber: 1)
  354. }
  355. if self.content != 0 {
  356. try visitor.visitSingularUInt32Field(value: self.content, fieldNumber: 2)
  357. }
  358. try unknownFields.traverse(visitor: &visitor)
  359. }
  360. static func ==(lhs: PayloadParameters, rhs: PayloadParameters) -> Bool {
  361. if lhs.size != rhs.size {return false}
  362. if lhs.content != rhs.content {return false}
  363. if lhs.unknownFields != rhs.unknownFields {return false}
  364. return true
  365. }
  366. }
  367. extension ControlOutput: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  368. static let protoMessageName: String = "ControlOutput"
  369. static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
  370. 1: .same(proto: "payload"),
  371. ]
  372. mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
  373. while let fieldNumber = try decoder.nextFieldNumber() {
  374. // The use of inline closures is to circumvent an issue where the compiler
  375. // allocates stack space for every case branch when no optimizations are
  376. // enabled. https://github.com/apple/swift-protobuf/issues/1034
  377. switch fieldNumber {
  378. case 1: try { try decoder.decodeSingularBytesField(value: &self.payload) }()
  379. default: break
  380. }
  381. }
  382. }
  383. func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
  384. if !self.payload.isEmpty {
  385. try visitor.visitSingularBytesField(value: self.payload, fieldNumber: 1)
  386. }
  387. try unknownFields.traverse(visitor: &visitor)
  388. }
  389. static func ==(lhs: ControlOutput, rhs: ControlOutput) -> Bool {
  390. if lhs.payload != rhs.payload {return false}
  391. if lhs.unknownFields != rhs.unknownFields {return false}
  392. return true
  393. }
  394. }