helloworld.grpc.swift 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /// Copyright 2015 gRPC authors.
  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: helloworld.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 Helloworld_Greeter {
  25. internal static let descriptor = GRPCCore.ServiceDescriptor.helloworld_Greeter
  26. internal enum Method {
  27. internal enum SayHello {
  28. internal typealias Input = Helloworld_HelloRequest
  29. internal typealias Output = Helloworld_HelloReply
  30. internal static let descriptor = GRPCCore.MethodDescriptor(
  31. service: Helloworld_Greeter.descriptor.fullyQualifiedService,
  32. method: "SayHello"
  33. )
  34. }
  35. internal static let descriptors: [GRPCCore.MethodDescriptor] = [
  36. SayHello.descriptor
  37. ]
  38. }
  39. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  40. internal typealias StreamingServiceProtocol = Helloworld_GreeterStreamingServiceProtocol
  41. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  42. internal typealias ServiceProtocol = Helloworld_GreeterServiceProtocol
  43. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  44. internal typealias ClientProtocol = Helloworld_GreeterClientProtocol
  45. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  46. internal typealias Client = Helloworld_GreeterClient
  47. }
  48. extension GRPCCore.ServiceDescriptor {
  49. internal static let helloworld_Greeter = Self(
  50. package: "helloworld",
  51. service: "Greeter"
  52. )
  53. }
  54. /// The greeting service definition.
  55. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  56. internal protocol Helloworld_GreeterStreamingServiceProtocol: GRPCCore.RegistrableRPCService {
  57. /// Sends a greeting
  58. func sayHello(
  59. request: GRPCCore.ServerRequest.Stream<Helloworld_HelloRequest>,
  60. context: GRPCCore.ServerContext
  61. ) async throws -> GRPCCore.ServerResponse.Stream<Helloworld_HelloReply>
  62. }
  63. /// Conformance to `GRPCCore.RegistrableRPCService`.
  64. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  65. extension Helloworld_Greeter.StreamingServiceProtocol {
  66. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  67. internal func registerMethods(with router: inout GRPCCore.RPCRouter) {
  68. router.registerHandler(
  69. forMethod: Helloworld_Greeter.Method.SayHello.descriptor,
  70. deserializer: GRPCProtobuf.ProtobufDeserializer<Helloworld_HelloRequest>(),
  71. serializer: GRPCProtobuf.ProtobufSerializer<Helloworld_HelloReply>(),
  72. handler: { request, context in
  73. try await self.sayHello(
  74. request: request,
  75. context: context
  76. )
  77. }
  78. )
  79. }
  80. }
  81. /// The greeting service definition.
  82. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  83. internal protocol Helloworld_GreeterServiceProtocol: Helloworld_Greeter.StreamingServiceProtocol {
  84. /// Sends a greeting
  85. func sayHello(
  86. request: GRPCCore.ServerRequest.Single<Helloworld_HelloRequest>,
  87. context: GRPCCore.ServerContext
  88. ) async throws -> GRPCCore.ServerResponse.Single<Helloworld_HelloReply>
  89. }
  90. /// Partial conformance to `Helloworld_GreeterStreamingServiceProtocol`.
  91. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  92. extension Helloworld_Greeter.ServiceProtocol {
  93. internal func sayHello(
  94. request: GRPCCore.ServerRequest.Stream<Helloworld_HelloRequest>,
  95. context: GRPCCore.ServerContext
  96. ) async throws -> GRPCCore.ServerResponse.Stream<Helloworld_HelloReply> {
  97. let response = try await self.sayHello(
  98. request: GRPCCore.ServerRequest.Single(stream: request),
  99. context: context
  100. )
  101. return GRPCCore.ServerResponse.Stream(single: response)
  102. }
  103. }
  104. /// The greeting service definition.
  105. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  106. internal protocol Helloworld_GreeterClientProtocol: Sendable {
  107. /// Sends a greeting
  108. func sayHello<R>(
  109. request: GRPCCore.ClientRequest.Single<Helloworld_HelloRequest>,
  110. serializer: some GRPCCore.MessageSerializer<Helloworld_HelloRequest>,
  111. deserializer: some GRPCCore.MessageDeserializer<Helloworld_HelloReply>,
  112. options: GRPCCore.CallOptions,
  113. _ body: @Sendable @escaping (GRPCCore.ClientResponse.Single<Helloworld_HelloReply>) async throws -> R
  114. ) async throws -> R where R: Sendable
  115. }
  116. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  117. extension Helloworld_Greeter.ClientProtocol {
  118. internal func sayHello<R>(
  119. request: GRPCCore.ClientRequest.Single<Helloworld_HelloRequest>,
  120. options: GRPCCore.CallOptions = .defaults,
  121. _ body: @Sendable @escaping (GRPCCore.ClientResponse.Single<Helloworld_HelloReply>) async throws -> R = {
  122. try $0.message
  123. }
  124. ) async throws -> R where R: Sendable {
  125. try await self.sayHello(
  126. request: request,
  127. serializer: GRPCProtobuf.ProtobufSerializer<Helloworld_HelloRequest>(),
  128. deserializer: GRPCProtobuf.ProtobufDeserializer<Helloworld_HelloReply>(),
  129. options: options,
  130. body
  131. )
  132. }
  133. }
  134. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  135. extension Helloworld_Greeter.ClientProtocol {
  136. /// Sends a greeting
  137. internal func sayHello<Result>(
  138. _ message: Helloworld_HelloRequest,
  139. metadata: GRPCCore.Metadata = [:],
  140. options: GRPCCore.CallOptions = .defaults,
  141. onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse.Single<Helloworld_HelloReply>) async throws -> Result = {
  142. try $0.message
  143. }
  144. ) async throws -> Result where Result: Sendable {
  145. let request = GRPCCore.ClientRequest.Single<Helloworld_HelloRequest>(
  146. message: message,
  147. metadata: metadata
  148. )
  149. return try await self.sayHello(
  150. request: request,
  151. options: options,
  152. handleResponse
  153. )
  154. }
  155. }
  156. /// The greeting service definition.
  157. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  158. internal struct Helloworld_GreeterClient: Helloworld_Greeter.ClientProtocol {
  159. private let client: GRPCCore.GRPCClient
  160. internal init(wrapping client: GRPCCore.GRPCClient) {
  161. self.client = client
  162. }
  163. /// Sends a greeting
  164. internal func sayHello<R>(
  165. request: GRPCCore.ClientRequest.Single<Helloworld_HelloRequest>,
  166. serializer: some GRPCCore.MessageSerializer<Helloworld_HelloRequest>,
  167. deserializer: some GRPCCore.MessageDeserializer<Helloworld_HelloReply>,
  168. options: GRPCCore.CallOptions = .defaults,
  169. _ body: @Sendable @escaping (GRPCCore.ClientResponse.Single<Helloworld_HelloReply>) async throws -> R = {
  170. try $0.message
  171. }
  172. ) async throws -> R where R: Sendable {
  173. try await self.client.unary(
  174. request: request,
  175. descriptor: Helloworld_Greeter.Method.SayHello.descriptor,
  176. serializer: serializer,
  177. deserializer: deserializer,
  178. options: options,
  179. handler: body
  180. )
  181. }
  182. }