|
|
@@ -0,0 +1,344 @@
|
|
|
+// 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<Echo_EchoRequest>) async throws -> ServerResponse.Stream<Echo_EchoResponse>
|
|
|
+
|
|
|
+ /// Splits a request into words and returns each word in a stream of messages.
|
|
|
+ func expand(request: ServerRequest.Stream<Echo_EchoRequest>) async throws -> ServerResponse.Stream<Echo_EchoResponse>
|
|
|
+
|
|
|
+ /// Collects a stream of messages and returns them concatenated when the caller closes.
|
|
|
+ func collect(request: ServerRequest.Stream<Echo_EchoRequest>) async throws -> ServerResponse.Stream<Echo_EchoResponse>
|
|
|
+
|
|
|
+ /// Streams back messages as they are received in an input stream.
|
|
|
+ func update(request: ServerRequest.Stream<Echo_EchoRequest>) async throws -> ServerResponse.Stream<Echo_EchoResponse>
|
|
|
+}
|
|
|
+
|
|
|
+/// 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<Echo_EchoRequest>(),
|
|
|
+ serializer: ProtobufSerializer<Echo_EchoResponse>(),
|
|
|
+ handler: { request in
|
|
|
+ try await self.get(request: request)
|
|
|
+ }
|
|
|
+ )
|
|
|
+ router.registerHandler(
|
|
|
+ forMethod: Echo_Echo.Method.Expand.descriptor,
|
|
|
+ deserializer: ProtobufDeserializer<Echo_EchoRequest>(),
|
|
|
+ serializer: ProtobufSerializer<Echo_EchoResponse>(),
|
|
|
+ handler: { request in
|
|
|
+ try await self.expand(request: request)
|
|
|
+ }
|
|
|
+ )
|
|
|
+ router.registerHandler(
|
|
|
+ forMethod: Echo_Echo.Method.Collect.descriptor,
|
|
|
+ deserializer: ProtobufDeserializer<Echo_EchoRequest>(),
|
|
|
+ serializer: ProtobufSerializer<Echo_EchoResponse>(),
|
|
|
+ handler: { request in
|
|
|
+ try await self.collect(request: request)
|
|
|
+ }
|
|
|
+ )
|
|
|
+ router.registerHandler(
|
|
|
+ forMethod: Echo_Echo.Method.Update.descriptor,
|
|
|
+ deserializer: ProtobufDeserializer<Echo_EchoRequest>(),
|
|
|
+ serializer: ProtobufSerializer<Echo_EchoResponse>(),
|
|
|
+ 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<Echo_EchoRequest>) async throws -> ServerResponse.Single<Echo_EchoResponse>
|
|
|
+
|
|
|
+ /// Splits a request into words and returns each word in a stream of messages.
|
|
|
+ func expand(request: ServerRequest.Single<Echo_EchoRequest>) async throws -> ServerResponse.Stream<Echo_EchoResponse>
|
|
|
+
|
|
|
+ /// Collects a stream of messages and returns them concatenated when the caller closes.
|
|
|
+ func collect(request: ServerRequest.Stream<Echo_EchoRequest>) async throws -> ServerResponse.Single<Echo_EchoResponse>
|
|
|
+
|
|
|
+ /// Streams back messages as they are received in an input stream.
|
|
|
+ func update(request: ServerRequest.Stream<Echo_EchoRequest>) async throws -> ServerResponse.Stream<Echo_EchoResponse>
|
|
|
+}
|
|
|
+
|
|
|
+/// 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<Echo_EchoRequest>) async throws -> ServerResponse.Stream<Echo_EchoResponse> {
|
|
|
+ let response = try await self.get(request: ServerRequest.Single(stream: request))
|
|
|
+ return ServerResponse.Stream(single: response)
|
|
|
+ }
|
|
|
+
|
|
|
+ internal func expand(request: ServerRequest.Stream<Echo_EchoRequest>) async throws -> ServerResponse.Stream<Echo_EchoResponse> {
|
|
|
+ let response = try await self.expand(request: ServerRequest.Single(stream: request))
|
|
|
+ return response
|
|
|
+ }
|
|
|
+
|
|
|
+ internal func collect(request: ServerRequest.Stream<Echo_EchoRequest>) async throws -> ServerResponse.Stream<Echo_EchoResponse> {
|
|
|
+ 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<R>(
|
|
|
+ request: ClientRequest.Single<Echo_EchoRequest>,
|
|
|
+ serializer: some MessageSerializer<Echo_EchoRequest>,
|
|
|
+ deserializer: some MessageDeserializer<Echo_EchoResponse>,
|
|
|
+ options: CallOptions,
|
|
|
+ _ body: @Sendable @escaping (ClientResponse.Single<Echo_EchoResponse>) 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<R>(
|
|
|
+ request: ClientRequest.Single<Echo_EchoRequest>,
|
|
|
+ serializer: some MessageSerializer<Echo_EchoRequest>,
|
|
|
+ deserializer: some MessageDeserializer<Echo_EchoResponse>,
|
|
|
+ options: CallOptions,
|
|
|
+ _ body: @Sendable @escaping (ClientResponse.Stream<Echo_EchoResponse>) async throws -> R
|
|
|
+ ) async throws -> R where R: Sendable
|
|
|
+
|
|
|
+ /// Collects a stream of messages and returns them concatenated when the caller closes.
|
|
|
+ func collect<R>(
|
|
|
+ request: ClientRequest.Stream<Echo_EchoRequest>,
|
|
|
+ serializer: some MessageSerializer<Echo_EchoRequest>,
|
|
|
+ deserializer: some MessageDeserializer<Echo_EchoResponse>,
|
|
|
+ options: CallOptions,
|
|
|
+ _ body: @Sendable @escaping (ClientResponse.Single<Echo_EchoResponse>) async throws -> R
|
|
|
+ ) async throws -> R where R: Sendable
|
|
|
+
|
|
|
+ /// Streams back messages as they are received in an input stream.
|
|
|
+ func update<R>(
|
|
|
+ request: ClientRequest.Stream<Echo_EchoRequest>,
|
|
|
+ serializer: some MessageSerializer<Echo_EchoRequest>,
|
|
|
+ deserializer: some MessageDeserializer<Echo_EchoResponse>,
|
|
|
+ options: CallOptions,
|
|
|
+ _ body: @Sendable @escaping (ClientResponse.Stream<Echo_EchoResponse>) 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<R>(
|
|
|
+ request: ClientRequest.Single<Echo_EchoRequest>,
|
|
|
+ options: CallOptions = .defaults,
|
|
|
+ _ body: @Sendable @escaping (ClientResponse.Single<Echo_EchoResponse>) async throws -> R
|
|
|
+ ) async throws -> R where R: Sendable {
|
|
|
+ try await self.get(
|
|
|
+ request: request,
|
|
|
+ serializer: ProtobufSerializer<Echo_EchoRequest>(),
|
|
|
+ deserializer: ProtobufDeserializer<Echo_EchoResponse>(),
|
|
|
+ options: options,
|
|
|
+ body
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ internal func expand<R>(
|
|
|
+ request: ClientRequest.Single<Echo_EchoRequest>,
|
|
|
+ options: CallOptions = .defaults,
|
|
|
+ _ body: @Sendable @escaping (ClientResponse.Stream<Echo_EchoResponse>) async throws -> R
|
|
|
+ ) async throws -> R where R: Sendable {
|
|
|
+ try await self.expand(
|
|
|
+ request: request,
|
|
|
+ serializer: ProtobufSerializer<Echo_EchoRequest>(),
|
|
|
+ deserializer: ProtobufDeserializer<Echo_EchoResponse>(),
|
|
|
+ options: options,
|
|
|
+ body
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ internal func collect<R>(
|
|
|
+ request: ClientRequest.Stream<Echo_EchoRequest>,
|
|
|
+ options: CallOptions = .defaults,
|
|
|
+ _ body: @Sendable @escaping (ClientResponse.Single<Echo_EchoResponse>) async throws -> R
|
|
|
+ ) async throws -> R where R: Sendable {
|
|
|
+ try await self.collect(
|
|
|
+ request: request,
|
|
|
+ serializer: ProtobufSerializer<Echo_EchoRequest>(),
|
|
|
+ deserializer: ProtobufDeserializer<Echo_EchoResponse>(),
|
|
|
+ options: options,
|
|
|
+ body
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ internal func update<R>(
|
|
|
+ request: ClientRequest.Stream<Echo_EchoRequest>,
|
|
|
+ options: CallOptions = .defaults,
|
|
|
+ _ body: @Sendable @escaping (ClientResponse.Stream<Echo_EchoResponse>) async throws -> R
|
|
|
+ ) async throws -> R where R: Sendable {
|
|
|
+ try await self.update(
|
|
|
+ request: request,
|
|
|
+ serializer: ProtobufSerializer<Echo_EchoRequest>(),
|
|
|
+ deserializer: ProtobufDeserializer<Echo_EchoResponse>(),
|
|
|
+ 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<R>(
|
|
|
+ request: ClientRequest.Single<Echo_EchoRequest>,
|
|
|
+ serializer: some MessageSerializer<Echo_EchoRequest>,
|
|
|
+ deserializer: some MessageDeserializer<Echo_EchoResponse>,
|
|
|
+ options: CallOptions = .defaults,
|
|
|
+ _ body: @Sendable @escaping (ClientResponse.Single<Echo_EchoResponse>) 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<R>(
|
|
|
+ request: ClientRequest.Single<Echo_EchoRequest>,
|
|
|
+ serializer: some MessageSerializer<Echo_EchoRequest>,
|
|
|
+ deserializer: some MessageDeserializer<Echo_EchoResponse>,
|
|
|
+ options: CallOptions = .defaults,
|
|
|
+ _ body: @Sendable @escaping (ClientResponse.Stream<Echo_EchoResponse>) 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<R>(
|
|
|
+ request: ClientRequest.Stream<Echo_EchoRequest>,
|
|
|
+ serializer: some MessageSerializer<Echo_EchoRequest>,
|
|
|
+ deserializer: some MessageDeserializer<Echo_EchoResponse>,
|
|
|
+ options: CallOptions = .defaults,
|
|
|
+ _ body: @Sendable @escaping (ClientResponse.Single<Echo_EchoResponse>) 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<R>(
|
|
|
+ request: ClientRequest.Stream<Echo_EchoRequest>,
|
|
|
+ serializer: some MessageSerializer<Echo_EchoRequest>,
|
|
|
+ deserializer: some MessageDeserializer<Echo_EchoResponse>,
|
|
|
+ options: CallOptions = .defaults,
|
|
|
+ _ body: @Sendable @escaping (ClientResponse.Stream<Echo_EchoResponse>) 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
|
|
|
+ )
|
|
|
+ }
|
|
|
+}
|