2
0

echo.grpc.swift 14 KB

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