// Copyright (c) 2015, Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // DO NOT EDIT. // swift-format-ignore-file // // Generated by the gRPC Swift generator plugin for the protocol buffer compiler. // Source: echo.proto // // For information on using the generated types, please see the documentation: // https://github.com/grpc/grpc-swift import GRPCCore import GRPCProtobuf internal enum Echo_Echo { internal enum Method { internal enum Get { internal typealias Input = Echo_EchoRequest internal typealias Output = Echo_EchoResponse internal static let descriptor = MethodDescriptor( service: "echo.Echo", method: "Get" ) } internal enum Expand { internal typealias Input = Echo_EchoRequest internal typealias Output = Echo_EchoResponse internal static let descriptor = MethodDescriptor( service: "echo.Echo", method: "Expand" ) } internal enum Collect { internal typealias Input = Echo_EchoRequest internal typealias Output = Echo_EchoResponse internal static let descriptor = MethodDescriptor( service: "echo.Echo", method: "Collect" ) } internal enum Update { internal typealias Input = Echo_EchoRequest internal typealias Output = Echo_EchoResponse internal static let descriptor = MethodDescriptor( service: "echo.Echo", method: "Update" ) } internal static let descriptors: [MethodDescriptor] = [ Get.descriptor, Expand.descriptor, Collect.descriptor, Update.descriptor ] } @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) internal typealias StreamingServiceProtocol = Echo_EchoStreamingServiceProtocol @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) internal typealias ServiceProtocol = Echo_EchoServiceProtocol @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) internal typealias ClientProtocol = Echo_EchoClientProtocol @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) internal typealias Client = Echo_EchoClient } @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) internal protocol Echo_EchoStreamingServiceProtocol: GRPCCore.RegistrableRPCService { /// Immediately returns an echo of a request. func get(request: ServerRequest.Stream) async throws -> ServerResponse.Stream /// Splits a request into words and returns each word in a stream of messages. func expand(request: ServerRequest.Stream) async throws -> ServerResponse.Stream /// Collects a stream of messages and returns them concatenated when the caller closes. func collect(request: ServerRequest.Stream) async throws -> ServerResponse.Stream /// Streams back messages as they are received in an input stream. func update(request: ServerRequest.Stream) async throws -> ServerResponse.Stream } /// Conformance to `GRPCCore.RegistrableRPCService`. @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) extension Echo_Echo.StreamingServiceProtocol { @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) internal func registerMethods(with router: inout GRPCCore.RPCRouter) { router.registerHandler( forMethod: Echo_Echo.Method.Get.descriptor, deserializer: ProtobufDeserializer(), serializer: ProtobufSerializer(), handler: { request in try await self.get(request: request) } ) router.registerHandler( forMethod: Echo_Echo.Method.Expand.descriptor, deserializer: ProtobufDeserializer(), serializer: ProtobufSerializer(), handler: { request in try await self.expand(request: request) } ) router.registerHandler( forMethod: Echo_Echo.Method.Collect.descriptor, deserializer: ProtobufDeserializer(), serializer: ProtobufSerializer(), handler: { request in try await self.collect(request: request) } ) router.registerHandler( forMethod: Echo_Echo.Method.Update.descriptor, deserializer: ProtobufDeserializer(), serializer: ProtobufSerializer(), handler: { request in try await self.update(request: request) } ) } } @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) internal protocol Echo_EchoServiceProtocol: Echo_Echo.StreamingServiceProtocol { /// Immediately returns an echo of a request. func get(request: ServerRequest.Single) async throws -> ServerResponse.Single /// Splits a request into words and returns each word in a stream of messages. func expand(request: ServerRequest.Single) async throws -> ServerResponse.Stream /// Collects a stream of messages and returns them concatenated when the caller closes. func collect(request: ServerRequest.Stream) async throws -> ServerResponse.Single /// Streams back messages as they are received in an input stream. func update(request: ServerRequest.Stream) async throws -> ServerResponse.Stream } /// Partial conformance to `Echo_EchoStreamingServiceProtocol`. @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) extension Echo_Echo.ServiceProtocol { internal func get(request: ServerRequest.Stream) async throws -> ServerResponse.Stream { let response = try await self.get(request: ServerRequest.Single(stream: request)) return ServerResponse.Stream(single: response) } internal func expand(request: ServerRequest.Stream) async throws -> ServerResponse.Stream { let response = try await self.expand(request: ServerRequest.Single(stream: request)) return response } internal func collect(request: ServerRequest.Stream) async throws -> ServerResponse.Stream { let response = try await self.collect(request: request) return ServerResponse.Stream(single: response) } } @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) internal protocol Echo_EchoClientProtocol: Sendable { /// Immediately returns an echo of a request. func get( request: ClientRequest.Single, serializer: some MessageSerializer, deserializer: some MessageDeserializer, options: CallOptions, _ body: @Sendable @escaping (ClientResponse.Single) async throws -> R ) async throws -> R where R: Sendable /// Splits a request into words and returns each word in a stream of messages. func expand( request: ClientRequest.Single, serializer: some MessageSerializer, deserializer: some MessageDeserializer, options: CallOptions, _ body: @Sendable @escaping (ClientResponse.Stream) async throws -> R ) async throws -> R where R: Sendable /// Collects a stream of messages and returns them concatenated when the caller closes. func collect( request: ClientRequest.Stream, serializer: some MessageSerializer, deserializer: some MessageDeserializer, options: CallOptions, _ body: @Sendable @escaping (ClientResponse.Single) async throws -> R ) async throws -> R where R: Sendable /// Streams back messages as they are received in an input stream. func update( request: ClientRequest.Stream, serializer: some MessageSerializer, deserializer: some MessageDeserializer, options: CallOptions, _ body: @Sendable @escaping (ClientResponse.Stream) async throws -> R ) async throws -> R where R: Sendable } @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) extension Echo_Echo.ClientProtocol { internal func get( request: ClientRequest.Single, options: CallOptions = .defaults, _ body: @Sendable @escaping (ClientResponse.Single) async throws -> R ) async throws -> R where R: Sendable { try await self.get( request: request, serializer: ProtobufSerializer(), deserializer: ProtobufDeserializer(), options: options, body ) } internal func expand( request: ClientRequest.Single, options: CallOptions = .defaults, _ body: @Sendable @escaping (ClientResponse.Stream) async throws -> R ) async throws -> R where R: Sendable { try await self.expand( request: request, serializer: ProtobufSerializer(), deserializer: ProtobufDeserializer(), options: options, body ) } internal func collect( request: ClientRequest.Stream, options: CallOptions = .defaults, _ body: @Sendable @escaping (ClientResponse.Single) async throws -> R ) async throws -> R where R: Sendable { try await self.collect( request: request, serializer: ProtobufSerializer(), deserializer: ProtobufDeserializer(), options: options, body ) } internal func update( request: ClientRequest.Stream, options: CallOptions = .defaults, _ body: @Sendable @escaping (ClientResponse.Stream) async throws -> R ) async throws -> R where R: Sendable { try await self.update( request: request, serializer: ProtobufSerializer(), deserializer: ProtobufDeserializer(), options: options, body ) } } @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) internal struct Echo_EchoClient: Echo_Echo.ClientProtocol { private let client: GRPCCore.GRPCClient internal init(client: GRPCCore.GRPCClient) { self.client = client } /// Immediately returns an echo of a request. internal func get( request: ClientRequest.Single, serializer: some MessageSerializer, deserializer: some MessageDeserializer, options: CallOptions = .defaults, _ body: @Sendable @escaping (ClientResponse.Single) async throws -> R ) async throws -> R where R: Sendable { try await self.client.unary( request: request, descriptor: Echo_Echo.Method.Get.descriptor, serializer: serializer, deserializer: deserializer, options: options, handler: body ) } /// Splits a request into words and returns each word in a stream of messages. internal func expand( request: ClientRequest.Single, serializer: some MessageSerializer, deserializer: some MessageDeserializer, options: CallOptions = .defaults, _ body: @Sendable @escaping (ClientResponse.Stream) async throws -> R ) async throws -> R where R: Sendable { try await self.client.serverStreaming( request: request, descriptor: Echo_Echo.Method.Expand.descriptor, serializer: serializer, deserializer: deserializer, options: options, handler: body ) } /// Collects a stream of messages and returns them concatenated when the caller closes. internal func collect( request: ClientRequest.Stream, serializer: some MessageSerializer, deserializer: some MessageDeserializer, options: CallOptions = .defaults, _ body: @Sendable @escaping (ClientResponse.Single) async throws -> R ) async throws -> R where R: Sendable { try await self.client.clientStreaming( request: request, descriptor: Echo_Echo.Method.Collect.descriptor, serializer: serializer, deserializer: deserializer, options: options, handler: body ) } /// Streams back messages as they are received in an input stream. internal func update( request: ClientRequest.Stream, serializer: some MessageSerializer, deserializer: some MessageDeserializer, options: CallOptions = .defaults, _ body: @Sendable @escaping (ClientResponse.Stream) async throws -> R ) async throws -> R where R: Sendable { try await self.client.bidirectionalStreaming( request: request, descriptor: Echo_Echo.Method.Update.descriptor, serializer: serializer, deserializer: deserializer, options: options, handler: body ) } }