control.grpc.swift 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  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 static let descriptor = ServiceDescriptor.Control
  27. internal enum Method {
  28. internal enum Unary {
  29. internal typealias Input = ControlInput
  30. internal typealias Output = ControlOutput
  31. internal static let descriptor = MethodDescriptor(
  32. service: Control.descriptor.fullyQualifiedService,
  33. method: "Unary"
  34. )
  35. }
  36. internal enum ServerStream {
  37. internal typealias Input = ControlInput
  38. internal typealias Output = ControlOutput
  39. internal static let descriptor = MethodDescriptor(
  40. service: Control.descriptor.fullyQualifiedService,
  41. method: "ServerStream"
  42. )
  43. }
  44. internal enum ClientStream {
  45. internal typealias Input = ControlInput
  46. internal typealias Output = ControlOutput
  47. internal static let descriptor = MethodDescriptor(
  48. service: Control.descriptor.fullyQualifiedService,
  49. method: "ClientStream"
  50. )
  51. }
  52. internal enum BidiStream {
  53. internal typealias Input = ControlInput
  54. internal typealias Output = ControlOutput
  55. internal static let descriptor = MethodDescriptor(
  56. service: Control.descriptor.fullyQualifiedService,
  57. method: "BidiStream"
  58. )
  59. }
  60. internal static let descriptors: [MethodDescriptor] = [
  61. Unary.descriptor,
  62. ServerStream.descriptor,
  63. ClientStream.descriptor,
  64. BidiStream.descriptor
  65. ]
  66. }
  67. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  68. internal typealias StreamingServiceProtocol = ControlStreamingServiceProtocol
  69. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  70. internal typealias ServiceProtocol = ControlServiceProtocol
  71. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  72. internal typealias ClientProtocol = ControlClientProtocol
  73. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  74. internal typealias Client = ControlClient
  75. }
  76. extension ServiceDescriptor {
  77. internal static let Control = Self(
  78. package: "",
  79. service: "Control"
  80. )
  81. }
  82. /// A controllable service for testing.
  83. ///
  84. /// The control service has one RPC of each kind, the input to each RPC controls
  85. /// the output.
  86. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  87. internal protocol ControlStreamingServiceProtocol: GRPCCore.RegistrableRPCService {
  88. func unary(request: ServerRequest.Stream<ControlInput>) async throws -> ServerResponse.Stream<ControlOutput>
  89. func serverStream(request: ServerRequest.Stream<ControlInput>) async throws -> ServerResponse.Stream<ControlOutput>
  90. func clientStream(request: ServerRequest.Stream<ControlInput>) async throws -> ServerResponse.Stream<ControlOutput>
  91. func bidiStream(request: ServerRequest.Stream<ControlInput>) async throws -> ServerResponse.Stream<ControlOutput>
  92. }
  93. /// Conformance to `GRPCCore.RegistrableRPCService`.
  94. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  95. extension Control.StreamingServiceProtocol {
  96. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  97. internal func registerMethods(with router: inout GRPCCore.RPCRouter) {
  98. router.registerHandler(
  99. forMethod: Control.Method.Unary.descriptor,
  100. deserializer: ProtobufDeserializer<ControlInput>(),
  101. serializer: ProtobufSerializer<ControlOutput>(),
  102. handler: { request in
  103. try await self.unary(request: request)
  104. }
  105. )
  106. router.registerHandler(
  107. forMethod: Control.Method.ServerStream.descriptor,
  108. deserializer: ProtobufDeserializer<ControlInput>(),
  109. serializer: ProtobufSerializer<ControlOutput>(),
  110. handler: { request in
  111. try await self.serverStream(request: request)
  112. }
  113. )
  114. router.registerHandler(
  115. forMethod: Control.Method.ClientStream.descriptor,
  116. deserializer: ProtobufDeserializer<ControlInput>(),
  117. serializer: ProtobufSerializer<ControlOutput>(),
  118. handler: { request in
  119. try await self.clientStream(request: request)
  120. }
  121. )
  122. router.registerHandler(
  123. forMethod: Control.Method.BidiStream.descriptor,
  124. deserializer: ProtobufDeserializer<ControlInput>(),
  125. serializer: ProtobufSerializer<ControlOutput>(),
  126. handler: { request in
  127. try await self.bidiStream(request: request)
  128. }
  129. )
  130. }
  131. }
  132. /// A controllable service for testing.
  133. ///
  134. /// The control service has one RPC of each kind, the input to each RPC controls
  135. /// the output.
  136. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  137. internal protocol ControlServiceProtocol: Control.StreamingServiceProtocol {
  138. func unary(request: ServerRequest.Single<ControlInput>) async throws -> ServerResponse.Single<ControlOutput>
  139. func serverStream(request: ServerRequest.Single<ControlInput>) async throws -> ServerResponse.Stream<ControlOutput>
  140. func clientStream(request: ServerRequest.Stream<ControlInput>) async throws -> ServerResponse.Single<ControlOutput>
  141. func bidiStream(request: ServerRequest.Stream<ControlInput>) async throws -> ServerResponse.Stream<ControlOutput>
  142. }
  143. /// Partial conformance to `ControlStreamingServiceProtocol`.
  144. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  145. extension Control.ServiceProtocol {
  146. internal func unary(request: ServerRequest.Stream<ControlInput>) async throws -> ServerResponse.Stream<ControlOutput> {
  147. let response = try await self.unary(request: ServerRequest.Single(stream: request))
  148. return ServerResponse.Stream(single: response)
  149. }
  150. internal func serverStream(request: ServerRequest.Stream<ControlInput>) async throws -> ServerResponse.Stream<ControlOutput> {
  151. let response = try await self.serverStream(request: ServerRequest.Single(stream: request))
  152. return response
  153. }
  154. internal func clientStream(request: ServerRequest.Stream<ControlInput>) async throws -> ServerResponse.Stream<ControlOutput> {
  155. let response = try await self.clientStream(request: request)
  156. return ServerResponse.Stream(single: response)
  157. }
  158. }
  159. /// A controllable service for testing.
  160. ///
  161. /// The control service has one RPC of each kind, the input to each RPC controls
  162. /// the output.
  163. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  164. internal protocol ControlClientProtocol: Sendable {
  165. func unary<R>(
  166. request: ClientRequest.Single<ControlInput>,
  167. serializer: some MessageSerializer<ControlInput>,
  168. deserializer: some MessageDeserializer<ControlOutput>,
  169. options: CallOptions,
  170. _ body: @Sendable @escaping (ClientResponse.Single<ControlOutput>) async throws -> R
  171. ) async throws -> R where R: Sendable
  172. func serverStream<R>(
  173. request: ClientRequest.Single<ControlInput>,
  174. serializer: some MessageSerializer<ControlInput>,
  175. deserializer: some MessageDeserializer<ControlOutput>,
  176. options: CallOptions,
  177. _ body: @Sendable @escaping (ClientResponse.Stream<ControlOutput>) async throws -> R
  178. ) async throws -> R where R: Sendable
  179. func clientStream<R>(
  180. request: ClientRequest.Stream<ControlInput>,
  181. serializer: some MessageSerializer<ControlInput>,
  182. deserializer: some MessageDeserializer<ControlOutput>,
  183. options: CallOptions,
  184. _ body: @Sendable @escaping (ClientResponse.Single<ControlOutput>) async throws -> R
  185. ) async throws -> R where R: Sendable
  186. func bidiStream<R>(
  187. request: ClientRequest.Stream<ControlInput>,
  188. serializer: some MessageSerializer<ControlInput>,
  189. deserializer: some MessageDeserializer<ControlOutput>,
  190. options: CallOptions,
  191. _ body: @Sendable @escaping (ClientResponse.Stream<ControlOutput>) async throws -> R
  192. ) async throws -> R where R: Sendable
  193. }
  194. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  195. extension Control.ClientProtocol {
  196. internal func unary<R>(
  197. request: ClientRequest.Single<ControlInput>,
  198. options: CallOptions = .defaults,
  199. _ body: @Sendable @escaping (ClientResponse.Single<ControlOutput>) async throws -> R
  200. ) async throws -> R where R: Sendable {
  201. try await self.unary(
  202. request: request,
  203. serializer: ProtobufSerializer<ControlInput>(),
  204. deserializer: ProtobufDeserializer<ControlOutput>(),
  205. options: options,
  206. body
  207. )
  208. }
  209. internal func serverStream<R>(
  210. request: ClientRequest.Single<ControlInput>,
  211. options: CallOptions = .defaults,
  212. _ body: @Sendable @escaping (ClientResponse.Stream<ControlOutput>) async throws -> R
  213. ) async throws -> R where R: Sendable {
  214. try await self.serverStream(
  215. request: request,
  216. serializer: ProtobufSerializer<ControlInput>(),
  217. deserializer: ProtobufDeserializer<ControlOutput>(),
  218. options: options,
  219. body
  220. )
  221. }
  222. internal func clientStream<R>(
  223. request: ClientRequest.Stream<ControlInput>,
  224. options: CallOptions = .defaults,
  225. _ body: @Sendable @escaping (ClientResponse.Single<ControlOutput>) async throws -> R
  226. ) async throws -> R where R: Sendable {
  227. try await self.clientStream(
  228. request: request,
  229. serializer: ProtobufSerializer<ControlInput>(),
  230. deserializer: ProtobufDeserializer<ControlOutput>(),
  231. options: options,
  232. body
  233. )
  234. }
  235. internal func bidiStream<R>(
  236. request: ClientRequest.Stream<ControlInput>,
  237. options: CallOptions = .defaults,
  238. _ body: @Sendable @escaping (ClientResponse.Stream<ControlOutput>) async throws -> R
  239. ) async throws -> R where R: Sendable {
  240. try await self.bidiStream(
  241. request: request,
  242. serializer: ProtobufSerializer<ControlInput>(),
  243. deserializer: ProtobufDeserializer<ControlOutput>(),
  244. options: options,
  245. body
  246. )
  247. }
  248. }
  249. /// A controllable service for testing.
  250. ///
  251. /// The control service has one RPC of each kind, the input to each RPC controls
  252. /// the output.
  253. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  254. internal struct ControlClient: Control.ClientProtocol {
  255. private let client: GRPCCore.GRPCClient
  256. internal init(wrapping client: GRPCCore.GRPCClient) {
  257. self.client = client
  258. }
  259. internal func unary<R>(
  260. request: ClientRequest.Single<ControlInput>,
  261. serializer: some MessageSerializer<ControlInput>,
  262. deserializer: some MessageDeserializer<ControlOutput>,
  263. options: CallOptions = .defaults,
  264. _ body: @Sendable @escaping (ClientResponse.Single<ControlOutput>) async throws -> R
  265. ) async throws -> R where R: Sendable {
  266. try await self.client.unary(
  267. request: request,
  268. descriptor: Control.Method.Unary.descriptor,
  269. serializer: serializer,
  270. deserializer: deserializer,
  271. options: options,
  272. handler: body
  273. )
  274. }
  275. internal func serverStream<R>(
  276. request: ClientRequest.Single<ControlInput>,
  277. serializer: some MessageSerializer<ControlInput>,
  278. deserializer: some MessageDeserializer<ControlOutput>,
  279. options: CallOptions = .defaults,
  280. _ body: @Sendable @escaping (ClientResponse.Stream<ControlOutput>) async throws -> R
  281. ) async throws -> R where R: Sendable {
  282. try await self.client.serverStreaming(
  283. request: request,
  284. descriptor: Control.Method.ServerStream.descriptor,
  285. serializer: serializer,
  286. deserializer: deserializer,
  287. options: options,
  288. handler: body
  289. )
  290. }
  291. internal func clientStream<R>(
  292. request: ClientRequest.Stream<ControlInput>,
  293. serializer: some MessageSerializer<ControlInput>,
  294. deserializer: some MessageDeserializer<ControlOutput>,
  295. options: CallOptions = .defaults,
  296. _ body: @Sendable @escaping (ClientResponse.Single<ControlOutput>) async throws -> R
  297. ) async throws -> R where R: Sendable {
  298. try await self.client.clientStreaming(
  299. request: request,
  300. descriptor: Control.Method.ClientStream.descriptor,
  301. serializer: serializer,
  302. deserializer: deserializer,
  303. options: options,
  304. handler: body
  305. )
  306. }
  307. internal func bidiStream<R>(
  308. request: ClientRequest.Stream<ControlInput>,
  309. serializer: some MessageSerializer<ControlInput>,
  310. deserializer: some MessageDeserializer<ControlOutput>,
  311. options: CallOptions = .defaults,
  312. _ body: @Sendable @escaping (ClientResponse.Stream<ControlOutput>) async throws -> R
  313. ) async throws -> R where R: Sendable {
  314. try await self.client.bidirectionalStreaming(
  315. request: request,
  316. descriptor: Control.Method.BidiStream.descriptor,
  317. serializer: serializer,
  318. deserializer: deserializer,
  319. options: options,
  320. handler: body
  321. )
  322. }
  323. }