control.grpc.swift 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. //
  2. // Copyright 2024, gRPC Authors All rights reserved.
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. // DO NOT EDIT.
  16. // swift-format-ignore-file
  17. //
  18. // Generated by the gRPC Swift generator plugin for the protocol buffer compiler.
  19. // Source: control.proto
  20. //
  21. // For information on using the generated types, please see the documentation:
  22. // https://github.com/grpc/grpc-swift
  23. import GRPCCore
  24. import GRPCProtobuf
  25. internal enum Control {
  26. internal enum Method {
  27. internal enum Unary {
  28. internal typealias Input = ControlInput
  29. internal typealias Output = ControlOutput
  30. internal static let descriptor = MethodDescriptor(
  31. service: "Control",
  32. method: "Unary"
  33. )
  34. }
  35. internal enum ServerStream {
  36. internal typealias Input = ControlInput
  37. internal typealias Output = ControlOutput
  38. internal static let descriptor = MethodDescriptor(
  39. service: "Control",
  40. method: "ServerStream"
  41. )
  42. }
  43. internal enum ClientStream {
  44. internal typealias Input = ControlInput
  45. internal typealias Output = ControlOutput
  46. internal static let descriptor = MethodDescriptor(
  47. service: "Control",
  48. method: "ClientStream"
  49. )
  50. }
  51. internal enum BidiStream {
  52. internal typealias Input = ControlInput
  53. internal typealias Output = ControlOutput
  54. internal static let descriptor = MethodDescriptor(
  55. service: "Control",
  56. method: "BidiStream"
  57. )
  58. }
  59. internal static let descriptors: [MethodDescriptor] = [
  60. Unary.descriptor,
  61. ServerStream.descriptor,
  62. ClientStream.descriptor,
  63. BidiStream.descriptor
  64. ]
  65. }
  66. @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
  67. internal typealias StreamingServiceProtocol = ControlStreamingServiceProtocol
  68. @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
  69. internal typealias ServiceProtocol = ControlServiceProtocol
  70. @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
  71. internal typealias ClientProtocol = ControlClientProtocol
  72. @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
  73. internal typealias Client = ControlClient
  74. }
  75. /// A controllable service for testing.
  76. ///
  77. /// The control service has one RPC of each kind, the input to each RPC controls
  78. /// the output.
  79. @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
  80. internal protocol ControlStreamingServiceProtocol: GRPCCore.RegistrableRPCService {
  81. func unary(request: ServerRequest.Stream<Control.Method.Unary.Input>) async throws -> ServerResponse.Stream<Control.Method.Unary.Output>
  82. func serverStream(request: ServerRequest.Stream<Control.Method.ServerStream.Input>) async throws -> ServerResponse.Stream<Control.Method.ServerStream.Output>
  83. func clientStream(request: ServerRequest.Stream<Control.Method.ClientStream.Input>) async throws -> ServerResponse.Stream<Control.Method.ClientStream.Output>
  84. func bidiStream(request: ServerRequest.Stream<Control.Method.BidiStream.Input>) async throws -> ServerResponse.Stream<Control.Method.BidiStream.Output>
  85. }
  86. /// Conformance to `GRPCCore.RegistrableRPCService`.
  87. @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
  88. extension Control.StreamingServiceProtocol {
  89. @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
  90. internal func registerMethods(with router: inout GRPCCore.RPCRouter) {
  91. router.registerHandler(
  92. forMethod: Control.Method.Unary.descriptor,
  93. deserializer: ProtobufDeserializer<Control.Method.Unary.Input>(),
  94. serializer: ProtobufSerializer<Control.Method.Unary.Output>(),
  95. handler: { request in
  96. try await self.unary(request: request)
  97. }
  98. )
  99. router.registerHandler(
  100. forMethod: Control.Method.ServerStream.descriptor,
  101. deserializer: ProtobufDeserializer<Control.Method.ServerStream.Input>(),
  102. serializer: ProtobufSerializer<Control.Method.ServerStream.Output>(),
  103. handler: { request in
  104. try await self.serverStream(request: request)
  105. }
  106. )
  107. router.registerHandler(
  108. forMethod: Control.Method.ClientStream.descriptor,
  109. deserializer: ProtobufDeserializer<Control.Method.ClientStream.Input>(),
  110. serializer: ProtobufSerializer<Control.Method.ClientStream.Output>(),
  111. handler: { request in
  112. try await self.clientStream(request: request)
  113. }
  114. )
  115. router.registerHandler(
  116. forMethod: Control.Method.BidiStream.descriptor,
  117. deserializer: ProtobufDeserializer<Control.Method.BidiStream.Input>(),
  118. serializer: ProtobufSerializer<Control.Method.BidiStream.Output>(),
  119. handler: { request in
  120. try await self.bidiStream(request: request)
  121. }
  122. )
  123. }
  124. }
  125. /// A controllable service for testing.
  126. ///
  127. /// The control service has one RPC of each kind, the input to each RPC controls
  128. /// the output.
  129. @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
  130. internal protocol ControlServiceProtocol: Control.StreamingServiceProtocol {
  131. func unary(request: ServerRequest.Single<Control.Method.Unary.Input>) async throws -> ServerResponse.Single<Control.Method.Unary.Output>
  132. func serverStream(request: ServerRequest.Single<Control.Method.ServerStream.Input>) async throws -> ServerResponse.Stream<Control.Method.ServerStream.Output>
  133. func clientStream(request: ServerRequest.Stream<Control.Method.ClientStream.Input>) async throws -> ServerResponse.Single<Control.Method.ClientStream.Output>
  134. func bidiStream(request: ServerRequest.Stream<Control.Method.BidiStream.Input>) async throws -> ServerResponse.Stream<Control.Method.BidiStream.Output>
  135. }
  136. /// Partial conformance to `ControlStreamingServiceProtocol`.
  137. @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
  138. extension Control.ServiceProtocol {
  139. internal func unary(request: ServerRequest.Stream<Control.Method.Unary.Input>) async throws -> ServerResponse.Stream<Control.Method.Unary.Output> {
  140. let response = try await self.unary(request: ServerRequest.Single(stream: request))
  141. return ServerResponse.Stream(single: response)
  142. }
  143. internal func serverStream(request: ServerRequest.Stream<Control.Method.ServerStream.Input>) async throws -> ServerResponse.Stream<Control.Method.ServerStream.Output> {
  144. let response = try await self.serverStream(request: ServerRequest.Single(stream: request))
  145. return response
  146. }
  147. internal func clientStream(request: ServerRequest.Stream<Control.Method.ClientStream.Input>) async throws -> ServerResponse.Stream<Control.Method.ClientStream.Output> {
  148. let response = try await self.clientStream(request: request)
  149. return ServerResponse.Stream(single: response)
  150. }
  151. }
  152. /// A controllable service for testing.
  153. ///
  154. /// The control service has one RPC of each kind, the input to each RPC controls
  155. /// the output.
  156. @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
  157. internal protocol ControlClientProtocol: Sendable {
  158. func unary<R>(
  159. request: ClientRequest.Single<Control.Method.Unary.Input>,
  160. serializer: some MessageSerializer<Control.Method.Unary.Input>,
  161. deserializer: some MessageDeserializer<Control.Method.Unary.Output>,
  162. options: CallOptions,
  163. _ body: @Sendable @escaping (ClientResponse.Single<Control.Method.Unary.Output>) async throws -> R
  164. ) async throws -> R where R: Sendable
  165. func serverStream<R>(
  166. request: ClientRequest.Single<Control.Method.ServerStream.Input>,
  167. serializer: some MessageSerializer<Control.Method.ServerStream.Input>,
  168. deserializer: some MessageDeserializer<Control.Method.ServerStream.Output>,
  169. options: CallOptions,
  170. _ body: @Sendable @escaping (ClientResponse.Stream<Control.Method.ServerStream.Output>) async throws -> R
  171. ) async throws -> R where R: Sendable
  172. func clientStream<R>(
  173. request: ClientRequest.Stream<Control.Method.ClientStream.Input>,
  174. serializer: some MessageSerializer<Control.Method.ClientStream.Input>,
  175. deserializer: some MessageDeserializer<Control.Method.ClientStream.Output>,
  176. options: CallOptions,
  177. _ body: @Sendable @escaping (ClientResponse.Single<Control.Method.ClientStream.Output>) async throws -> R
  178. ) async throws -> R where R: Sendable
  179. func bidiStream<R>(
  180. request: ClientRequest.Stream<Control.Method.BidiStream.Input>,
  181. serializer: some MessageSerializer<Control.Method.BidiStream.Input>,
  182. deserializer: some MessageDeserializer<Control.Method.BidiStream.Output>,
  183. options: CallOptions,
  184. _ body: @Sendable @escaping (ClientResponse.Stream<Control.Method.BidiStream.Output>) async throws -> R
  185. ) async throws -> R where R: Sendable
  186. }
  187. @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
  188. extension Control.ClientProtocol {
  189. internal func unary<R>(
  190. request: ClientRequest.Single<Control.Method.Unary.Input>,
  191. options: CallOptions = .defaults,
  192. _ body: @Sendable @escaping (ClientResponse.Single<Control.Method.Unary.Output>) async throws -> R
  193. ) async throws -> R where R: Sendable {
  194. try await self.unary(
  195. request: request,
  196. serializer: ProtobufSerializer<Control.Method.Unary.Input>(),
  197. deserializer: ProtobufDeserializer<Control.Method.Unary.Output>(),
  198. options: options,
  199. body
  200. )
  201. }
  202. internal func serverStream<R>(
  203. request: ClientRequest.Single<Control.Method.ServerStream.Input>,
  204. options: CallOptions = .defaults,
  205. _ body: @Sendable @escaping (ClientResponse.Stream<Control.Method.ServerStream.Output>) async throws -> R
  206. ) async throws -> R where R: Sendable {
  207. try await self.serverStream(
  208. request: request,
  209. serializer: ProtobufSerializer<Control.Method.ServerStream.Input>(),
  210. deserializer: ProtobufDeserializer<Control.Method.ServerStream.Output>(),
  211. options: options,
  212. body
  213. )
  214. }
  215. internal func clientStream<R>(
  216. request: ClientRequest.Stream<Control.Method.ClientStream.Input>,
  217. options: CallOptions = .defaults,
  218. _ body: @Sendable @escaping (ClientResponse.Single<Control.Method.ClientStream.Output>) async throws -> R
  219. ) async throws -> R where R: Sendable {
  220. try await self.clientStream(
  221. request: request,
  222. serializer: ProtobufSerializer<Control.Method.ClientStream.Input>(),
  223. deserializer: ProtobufDeserializer<Control.Method.ClientStream.Output>(),
  224. options: options,
  225. body
  226. )
  227. }
  228. internal func bidiStream<R>(
  229. request: ClientRequest.Stream<Control.Method.BidiStream.Input>,
  230. options: CallOptions = .defaults,
  231. _ body: @Sendable @escaping (ClientResponse.Stream<Control.Method.BidiStream.Output>) async throws -> R
  232. ) async throws -> R where R: Sendable {
  233. try await self.bidiStream(
  234. request: request,
  235. serializer: ProtobufSerializer<Control.Method.BidiStream.Input>(),
  236. deserializer: ProtobufDeserializer<Control.Method.BidiStream.Output>(),
  237. options: options,
  238. body
  239. )
  240. }
  241. }
  242. /// A controllable service for testing.
  243. ///
  244. /// The control service has one RPC of each kind, the input to each RPC controls
  245. /// the output.
  246. @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
  247. internal struct ControlClient: Control.ClientProtocol {
  248. private let client: GRPCCore.GRPCClient
  249. internal init(client: GRPCCore.GRPCClient) {
  250. self.client = client
  251. }
  252. internal func unary<R>(
  253. request: ClientRequest.Single<Control.Method.Unary.Input>,
  254. serializer: some MessageSerializer<Control.Method.Unary.Input>,
  255. deserializer: some MessageDeserializer<Control.Method.Unary.Output>,
  256. options: CallOptions = .defaults,
  257. _ body: @Sendable @escaping (ClientResponse.Single<Control.Method.Unary.Output>) async throws -> R
  258. ) async throws -> R where R: Sendable {
  259. try await self.client.unary(
  260. request: request,
  261. descriptor: Control.Method.Unary.descriptor,
  262. serializer: serializer,
  263. deserializer: deserializer,
  264. options: options,
  265. handler: body
  266. )
  267. }
  268. internal func serverStream<R>(
  269. request: ClientRequest.Single<Control.Method.ServerStream.Input>,
  270. serializer: some MessageSerializer<Control.Method.ServerStream.Input>,
  271. deserializer: some MessageDeserializer<Control.Method.ServerStream.Output>,
  272. options: CallOptions = .defaults,
  273. _ body: @Sendable @escaping (ClientResponse.Stream<Control.Method.ServerStream.Output>) async throws -> R
  274. ) async throws -> R where R: Sendable {
  275. try await self.client.serverStreaming(
  276. request: request,
  277. descriptor: Control.Method.ServerStream.descriptor,
  278. serializer: serializer,
  279. deserializer: deserializer,
  280. options: options,
  281. handler: body
  282. )
  283. }
  284. internal func clientStream<R>(
  285. request: ClientRequest.Stream<Control.Method.ClientStream.Input>,
  286. serializer: some MessageSerializer<Control.Method.ClientStream.Input>,
  287. deserializer: some MessageDeserializer<Control.Method.ClientStream.Output>,
  288. options: CallOptions = .defaults,
  289. _ body: @Sendable @escaping (ClientResponse.Single<Control.Method.ClientStream.Output>) async throws -> R
  290. ) async throws -> R where R: Sendable {
  291. try await self.client.clientStreaming(
  292. request: request,
  293. descriptor: Control.Method.ClientStream.descriptor,
  294. serializer: serializer,
  295. deserializer: deserializer,
  296. options: options,
  297. handler: body
  298. )
  299. }
  300. internal func bidiStream<R>(
  301. request: ClientRequest.Stream<Control.Method.BidiStream.Input>,
  302. serializer: some MessageSerializer<Control.Method.BidiStream.Input>,
  303. deserializer: some MessageDeserializer<Control.Method.BidiStream.Output>,
  304. options: CallOptions = .defaults,
  305. _ body: @Sendable @escaping (ClientResponse.Stream<Control.Method.BidiStream.Output>) async throws -> R
  306. ) async throws -> R where R: Sendable {
  307. try await self.client.bidirectionalStreaming(
  308. request: request,
  309. descriptor: Control.Method.BidiStream.descriptor,
  310. serializer: serializer,
  311. deserializer: deserializer,
  312. options: options,
  313. handler: body
  314. )
  315. }
  316. }