helloworld.grpc.swift 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. internal import GRPCCore
  23. internal 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(request: GRPCCore.ServerRequest.Stream<Helloworld_HelloRequest>) async throws -> GRPCCore.ServerResponse.Stream<Helloworld_HelloReply>
  59. }
  60. /// Conformance to `GRPCCore.RegistrableRPCService`.
  61. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  62. extension Helloworld_Greeter.StreamingServiceProtocol {
  63. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  64. internal func registerMethods(with router: inout GRPCCore.RPCRouter) {
  65. router.registerHandler(
  66. forMethod: Helloworld_Greeter.Method.SayHello.descriptor,
  67. deserializer: GRPCProtobuf.ProtobufDeserializer<Helloworld_HelloRequest>(),
  68. serializer: GRPCProtobuf.ProtobufSerializer<Helloworld_HelloReply>(),
  69. handler: { request in
  70. try await self.sayHello(request: request)
  71. }
  72. )
  73. }
  74. }
  75. /// The greeting service definition.
  76. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  77. internal protocol Helloworld_GreeterServiceProtocol: Helloworld_Greeter.StreamingServiceProtocol {
  78. /// Sends a greeting
  79. func sayHello(request: GRPCCore.ServerRequest.Single<Helloworld_HelloRequest>) async throws -> GRPCCore.ServerResponse.Single<Helloworld_HelloReply>
  80. }
  81. /// Partial conformance to `Helloworld_GreeterStreamingServiceProtocol`.
  82. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  83. extension Helloworld_Greeter.ServiceProtocol {
  84. internal func sayHello(request: GRPCCore.ServerRequest.Stream<Helloworld_HelloRequest>) async throws -> GRPCCore.ServerResponse.Stream<Helloworld_HelloReply> {
  85. let response = try await self.sayHello(request: GRPCCore.ServerRequest.Single(stream: request))
  86. return GRPCCore.ServerResponse.Stream(single: response)
  87. }
  88. }
  89. /// The greeting service definition.
  90. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  91. internal protocol Helloworld_GreeterClientProtocol: Sendable {
  92. /// Sends a greeting
  93. func sayHello<R>(
  94. request: GRPCCore.ClientRequest.Single<Helloworld_HelloRequest>,
  95. serializer: some GRPCCore.MessageSerializer<Helloworld_HelloRequest>,
  96. deserializer: some GRPCCore.MessageDeserializer<Helloworld_HelloReply>,
  97. options: GRPCCore.CallOptions,
  98. _ body: @Sendable @escaping (GRPCCore.ClientResponse.Single<Helloworld_HelloReply>) async throws -> R
  99. ) async throws -> R where R: Sendable
  100. }
  101. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  102. extension Helloworld_Greeter.ClientProtocol {
  103. internal func sayHello<R>(
  104. request: GRPCCore.ClientRequest.Single<Helloworld_HelloRequest>,
  105. options: GRPCCore.CallOptions = .defaults,
  106. _ body: @Sendable @escaping (GRPCCore.ClientResponse.Single<Helloworld_HelloReply>) async throws -> R = {
  107. try $0.message
  108. }
  109. ) async throws -> R where R: Sendable {
  110. try await self.sayHello(
  111. request: request,
  112. serializer: GRPCProtobuf.ProtobufSerializer<Helloworld_HelloRequest>(),
  113. deserializer: GRPCProtobuf.ProtobufDeserializer<Helloworld_HelloReply>(),
  114. options: options,
  115. body
  116. )
  117. }
  118. }
  119. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  120. extension Helloworld_Greeter.ClientProtocol {
  121. /// Sends a greeting
  122. internal func sayHello<Result>(
  123. _ message: Helloworld_HelloRequest,
  124. metadata: GRPCCore.Metadata = [:],
  125. options: GRPCCore.CallOptions = .defaults,
  126. onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse.Single<Helloworld_HelloReply>) async throws -> Result = {
  127. try $0.message
  128. }
  129. ) async throws -> Result where Result: Sendable {
  130. let request = GRPCCore.ClientRequest.Single<Helloworld_HelloRequest>(
  131. message: message,
  132. metadata: metadata
  133. )
  134. return try await self.sayHello(
  135. request: request,
  136. options: options,
  137. handleResponse
  138. )
  139. }
  140. }
  141. /// The greeting service definition.
  142. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  143. internal struct Helloworld_GreeterClient: Helloworld_Greeter.ClientProtocol {
  144. private let client: GRPCCore.GRPCClient
  145. internal init(wrapping client: GRPCCore.GRPCClient) {
  146. self.client = client
  147. }
  148. /// Sends a greeting
  149. internal func sayHello<R>(
  150. request: GRPCCore.ClientRequest.Single<Helloworld_HelloRequest>,
  151. serializer: some GRPCCore.MessageSerializer<Helloworld_HelloRequest>,
  152. deserializer: some GRPCCore.MessageDeserializer<Helloworld_HelloReply>,
  153. options: GRPCCore.CallOptions = .defaults,
  154. _ body: @Sendable @escaping (GRPCCore.ClientResponse.Single<Helloworld_HelloReply>) async throws -> R = {
  155. try $0.message
  156. }
  157. ) async throws -> R where R: Sendable {
  158. try await self.client.unary(
  159. request: request,
  160. descriptor: Helloworld_Greeter.Method.SayHello.descriptor,
  161. serializer: serializer,
  162. deserializer: deserializer,
  163. options: options,
  164. handler: body
  165. )
  166. }
  167. }