// Copyright 2015 gRPC authors. // // 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. /// An integration test service that covers all the method signature permutations /// of unary/streaming requests/responses. // DO NOT EDIT. // swift-format-ignore-file // // Generated by the gRPC Swift generator plugin for the protocol buffer compiler. // Source: grpc/testing/benchmark_service.proto // // For information on using the generated types, please see the documentation: // https://github.com/grpc/grpc-swift import GRPCCore import GRPCProtobuf internal enum Grpc_Testing_BenchmarkService { internal enum Method { internal enum UnaryCall { internal typealias Input = Grpc_Testing_SimpleRequest internal typealias Output = Grpc_Testing_SimpleResponse internal static let descriptor = MethodDescriptor( service: "grpc.testing.BenchmarkService", method: "UnaryCall" ) } internal enum StreamingCall { internal typealias Input = Grpc_Testing_SimpleRequest internal typealias Output = Grpc_Testing_SimpleResponse internal static let descriptor = MethodDescriptor( service: "grpc.testing.BenchmarkService", method: "StreamingCall" ) } internal enum StreamingFromClient { internal typealias Input = Grpc_Testing_SimpleRequest internal typealias Output = Grpc_Testing_SimpleResponse internal static let descriptor = MethodDescriptor( service: "grpc.testing.BenchmarkService", method: "StreamingFromClient" ) } internal enum StreamingFromServer { internal typealias Input = Grpc_Testing_SimpleRequest internal typealias Output = Grpc_Testing_SimpleResponse internal static let descriptor = MethodDescriptor( service: "grpc.testing.BenchmarkService", method: "StreamingFromServer" ) } internal enum StreamingBothWays { internal typealias Input = Grpc_Testing_SimpleRequest internal typealias Output = Grpc_Testing_SimpleResponse internal static let descriptor = MethodDescriptor( service: "grpc.testing.BenchmarkService", method: "StreamingBothWays" ) } internal static let descriptors: [MethodDescriptor] = [ UnaryCall.descriptor, StreamingCall.descriptor, StreamingFromClient.descriptor, StreamingFromServer.descriptor, StreamingBothWays.descriptor ] } @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) internal typealias StreamingServiceProtocol = Grpc_Testing_BenchmarkServiceStreamingServiceProtocol @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) internal typealias ServiceProtocol = Grpc_Testing_BenchmarkServiceServiceProtocol @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) internal typealias ClientProtocol = Grpc_Testing_BenchmarkServiceClientProtocol @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) internal typealias Client = Grpc_Testing_BenchmarkServiceClient } @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) internal protocol Grpc_Testing_BenchmarkServiceStreamingServiceProtocol: GRPCCore.RegistrableRPCService { /// One request followed by one response. /// The server returns the client payload as-is. func unaryCall(request: ServerRequest.Stream) async throws -> ServerResponse.Stream /// Repeated sequence of one request followed by one response. /// Should be called streaming ping-pong /// The server returns the client payload as-is on each response func streamingCall(request: ServerRequest.Stream) async throws -> ServerResponse.Stream /// Single-sided unbounded streaming from client to server /// The server returns the client payload as-is once the client does WritesDone func streamingFromClient(request: ServerRequest.Stream) async throws -> ServerResponse.Stream /// Single-sided unbounded streaming from server to client /// The server repeatedly returns the client payload as-is func streamingFromServer(request: ServerRequest.Stream) async throws -> ServerResponse.Stream /// Two-sided unbounded streaming between server to client /// Both sides send the content of their own choice to the other func streamingBothWays(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 Grpc_Testing_BenchmarkService.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: Grpc_Testing_BenchmarkService.Method.UnaryCall.descriptor, deserializer: ProtobufDeserializer(), serializer: ProtobufSerializer(), handler: { request in try await self.unaryCall(request: request) } ) router.registerHandler( forMethod: Grpc_Testing_BenchmarkService.Method.StreamingCall.descriptor, deserializer: ProtobufDeserializer(), serializer: ProtobufSerializer(), handler: { request in try await self.streamingCall(request: request) } ) router.registerHandler( forMethod: Grpc_Testing_BenchmarkService.Method.StreamingFromClient.descriptor, deserializer: ProtobufDeserializer(), serializer: ProtobufSerializer(), handler: { request in try await self.streamingFromClient(request: request) } ) router.registerHandler( forMethod: Grpc_Testing_BenchmarkService.Method.StreamingFromServer.descriptor, deserializer: ProtobufDeserializer(), serializer: ProtobufSerializer(), handler: { request in try await self.streamingFromServer(request: request) } ) router.registerHandler( forMethod: Grpc_Testing_BenchmarkService.Method.StreamingBothWays.descriptor, deserializer: ProtobufDeserializer(), serializer: ProtobufSerializer(), handler: { request in try await self.streamingBothWays(request: request) } ) } } @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) internal protocol Grpc_Testing_BenchmarkServiceServiceProtocol: Grpc_Testing_BenchmarkService.StreamingServiceProtocol { /// One request followed by one response. /// The server returns the client payload as-is. func unaryCall(request: ServerRequest.Single) async throws -> ServerResponse.Single /// Repeated sequence of one request followed by one response. /// Should be called streaming ping-pong /// The server returns the client payload as-is on each response func streamingCall(request: ServerRequest.Stream) async throws -> ServerResponse.Stream /// Single-sided unbounded streaming from client to server /// The server returns the client payload as-is once the client does WritesDone func streamingFromClient(request: ServerRequest.Stream) async throws -> ServerResponse.Single /// Single-sided unbounded streaming from server to client /// The server repeatedly returns the client payload as-is func streamingFromServer(request: ServerRequest.Single) async throws -> ServerResponse.Stream /// Two-sided unbounded streaming between server to client /// Both sides send the content of their own choice to the other func streamingBothWays(request: ServerRequest.Stream) async throws -> ServerResponse.Stream } /// Partial conformance to `Grpc_Testing_BenchmarkServiceStreamingServiceProtocol`. @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) extension Grpc_Testing_BenchmarkService.ServiceProtocol { internal func unaryCall(request: ServerRequest.Stream) async throws -> ServerResponse.Stream { let response = try await self.unaryCall(request: ServerRequest.Single(stream: request)) return ServerResponse.Stream(single: response) } internal func streamingFromClient(request: ServerRequest.Stream) async throws -> ServerResponse.Stream { let response = try await self.streamingFromClient(request: request) return ServerResponse.Stream(single: response) } internal func streamingFromServer(request: ServerRequest.Stream) async throws -> ServerResponse.Stream { let response = try await self.streamingFromServer(request: ServerRequest.Single(stream: request)) return response } } @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) internal protocol Grpc_Testing_BenchmarkServiceClientProtocol: Sendable { /// One request followed by one response. /// The server returns the client payload as-is. func unaryCall( 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 /// Repeated sequence of one request followed by one response. /// Should be called streaming ping-pong /// The server returns the client payload as-is on each response func streamingCall( 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 /// Single-sided unbounded streaming from client to server /// The server returns the client payload as-is once the client does WritesDone func streamingFromClient( 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 /// Single-sided unbounded streaming from server to client /// The server repeatedly returns the client payload as-is func streamingFromServer( 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 /// Two-sided unbounded streaming between server to client /// Both sides send the content of their own choice to the other func streamingBothWays( 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 Grpc_Testing_BenchmarkService.ClientProtocol { internal func unaryCall( request: ClientRequest.Single, options: CallOptions = .defaults, _ body: @Sendable @escaping (ClientResponse.Single) async throws -> R ) async throws -> R where R: Sendable { try await self.unaryCall( request: request, serializer: ProtobufSerializer(), deserializer: ProtobufDeserializer(), options: options, body ) } internal func streamingCall( request: ClientRequest.Stream, options: CallOptions = .defaults, _ body: @Sendable @escaping (ClientResponse.Stream) async throws -> R ) async throws -> R where R: Sendable { try await self.streamingCall( request: request, serializer: ProtobufSerializer(), deserializer: ProtobufDeserializer(), options: options, body ) } internal func streamingFromClient( request: ClientRequest.Stream, options: CallOptions = .defaults, _ body: @Sendable @escaping (ClientResponse.Single) async throws -> R ) async throws -> R where R: Sendable { try await self.streamingFromClient( request: request, serializer: ProtobufSerializer(), deserializer: ProtobufDeserializer(), options: options, body ) } internal func streamingFromServer( request: ClientRequest.Single, options: CallOptions = .defaults, _ body: @Sendable @escaping (ClientResponse.Stream) async throws -> R ) async throws -> R where R: Sendable { try await self.streamingFromServer( request: request, serializer: ProtobufSerializer(), deserializer: ProtobufDeserializer(), options: options, body ) } internal func streamingBothWays( request: ClientRequest.Stream, options: CallOptions = .defaults, _ body: @Sendable @escaping (ClientResponse.Stream) async throws -> R ) async throws -> R where R: Sendable { try await self.streamingBothWays( request: request, serializer: ProtobufSerializer(), deserializer: ProtobufDeserializer(), options: options, body ) } } @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) internal struct Grpc_Testing_BenchmarkServiceClient: Grpc_Testing_BenchmarkService.ClientProtocol { private let client: GRPCCore.GRPCClient internal init(client: GRPCCore.GRPCClient) { self.client = client } /// One request followed by one response. /// The server returns the client payload as-is. internal func unaryCall( 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: Grpc_Testing_BenchmarkService.Method.UnaryCall.descriptor, serializer: serializer, deserializer: deserializer, options: options, handler: body ) } /// Repeated sequence of one request followed by one response. /// Should be called streaming ping-pong /// The server returns the client payload as-is on each response internal func streamingCall( 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: Grpc_Testing_BenchmarkService.Method.StreamingCall.descriptor, serializer: serializer, deserializer: deserializer, options: options, handler: body ) } /// Single-sided unbounded streaming from client to server /// The server returns the client payload as-is once the client does WritesDone internal func streamingFromClient( 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: Grpc_Testing_BenchmarkService.Method.StreamingFromClient.descriptor, serializer: serializer, deserializer: deserializer, options: options, handler: body ) } /// Single-sided unbounded streaming from server to client /// The server repeatedly returns the client payload as-is internal func streamingFromServer( 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: Grpc_Testing_BenchmarkService.Method.StreamingFromServer.descriptor, serializer: serializer, deserializer: deserializer, options: options, handler: body ) } /// Two-sided unbounded streaming between server to client /// Both sides send the content of their own choice to the other internal func streamingBothWays( 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: Grpc_Testing_BenchmarkService.Method.StreamingBothWays.descriptor, serializer: serializer, deserializer: deserializer, options: options, handler: body ) } }