/// 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. // DO NOT EDIT. // swift-format-ignore-file // // Generated by the gRPC Swift generator plugin for the protocol buffer compiler. // Source: helloworld.proto // // For information on using the generated types, please see the documentation: // https://github.com/grpc/grpc-swift import GRPCCore import GRPCProtobuf // MARK: - helloworld.Greeter /// Namespace containing generated types for the "helloworld.Greeter" service. internal enum Helloworld_Greeter { /// Service descriptor for the "helloworld.Greeter" service. internal static let descriptor = GRPCCore.ServiceDescriptor(fullyQualifiedService: "helloworld.Greeter") /// Namespace for method metadata. internal enum Method { /// Namespace for "SayHello" metadata. internal enum SayHello { /// Request type for "SayHello". internal typealias Input = Helloworld_HelloRequest /// Response type for "SayHello". internal typealias Output = Helloworld_HelloReply /// Descriptor for "SayHello". internal static let descriptor = GRPCCore.MethodDescriptor( service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "helloworld.Greeter"), method: "SayHello" ) } /// Descriptors for all methods in the "helloworld.Greeter" service. internal static let descriptors: [GRPCCore.MethodDescriptor] = [ SayHello.descriptor ] } } extension GRPCCore.ServiceDescriptor { /// Service descriptor for the "helloworld.Greeter" service. internal static let helloworld_Greeter = GRPCCore.ServiceDescriptor(fullyQualifiedService: "helloworld.Greeter") } // MARK: helloworld.Greeter (server) extension Helloworld_Greeter { /// Streaming variant of the service protocol for the "helloworld.Greeter" service. /// /// This protocol is the lowest-level of the service protocols generated for this service /// giving you the most flexibility over the implementation of your service. This comes at /// the cost of more verbose and less strict APIs. Each RPC requires you to implement it in /// terms of a request stream and response stream. Where only a single request or response /// message is expected, you are responsible for enforcing this invariant is maintained. /// /// Where possible, prefer using the stricter, less-verbose ``ServiceProtocol`` /// or ``SimpleServiceProtocol`` instead. /// /// > Source IDL Documentation: /// > /// > The greeting service definition. internal protocol StreamingServiceProtocol: GRPCCore.RegistrableRPCService { /// Handle the "SayHello" method. /// /// > Source IDL Documentation: /// > /// > Sends a greeting /// /// - Parameters: /// - request: A streaming request of `Helloworld_HelloRequest` messages. /// - context: Context providing information about the RPC. /// - Throws: Any error which occurred during the processing of the request. Thrown errors /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted /// to an internal error. /// - Returns: A streaming response of `Helloworld_HelloReply` messages. func sayHello( request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext ) async throws -> GRPCCore.StreamingServerResponse } /// Service protocol for the "helloworld.Greeter" service. /// /// This protocol is higher level than ``StreamingServiceProtocol`` but lower level than /// the ``SimpleServiceProtocol``, it provides access to request and response metadata and /// trailing response metadata. If you don't need these then consider using /// the ``SimpleServiceProtocol``. If you need fine grained control over your RPCs then /// use ``StreamingServiceProtocol``. /// /// > Source IDL Documentation: /// > /// > The greeting service definition. internal protocol ServiceProtocol: Helloworld_Greeter.StreamingServiceProtocol { /// Handle the "SayHello" method. /// /// > Source IDL Documentation: /// > /// > Sends a greeting /// /// - Parameters: /// - request: A request containing a single `Helloworld_HelloRequest` message. /// - context: Context providing information about the RPC. /// - Throws: Any error which occurred during the processing of the request. Thrown errors /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted /// to an internal error. /// - Returns: A response containing a single `Helloworld_HelloReply` message. func sayHello( request: GRPCCore.ServerRequest, context: GRPCCore.ServerContext ) async throws -> GRPCCore.ServerResponse } /// Simple service protocol for the "helloworld.Greeter" service. /// /// This is the highest level protocol for the service. The API is the easiest to use but /// doesn't provide access to request or response metadata. If you need access to these /// then use ``ServiceProtocol`` instead. /// /// > Source IDL Documentation: /// > /// > The greeting service definition. internal protocol SimpleServiceProtocol: Helloworld_Greeter.ServiceProtocol { /// Handle the "SayHello" method. /// /// > Source IDL Documentation: /// > /// > Sends a greeting /// /// - Parameters: /// - request: A `Helloworld_HelloRequest` message. /// - context: Context providing information about the RPC. /// - Throws: Any error which occurred during the processing of the request. Thrown errors /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted /// to an internal error. /// - Returns: A `Helloworld_HelloReply` to respond with. func sayHello( request: Helloworld_HelloRequest, context: GRPCCore.ServerContext ) async throws -> Helloworld_HelloReply } } // Default implementation of 'registerMethods(with:)'. extension Helloworld_Greeter.StreamingServiceProtocol { internal func registerMethods(with router: inout GRPCCore.RPCRouter) { router.registerHandler( forMethod: Helloworld_Greeter.Method.SayHello.descriptor, deserializer: GRPCProtobuf.ProtobufDeserializer(), serializer: GRPCProtobuf.ProtobufSerializer(), handler: { request, context in try await self.sayHello( request: request, context: context ) } ) } } // Default implementation of streaming methods from 'StreamingServiceProtocol'. extension Helloworld_Greeter.ServiceProtocol { internal func sayHello( request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext ) async throws -> GRPCCore.StreamingServerResponse { let response = try await self.sayHello( request: GRPCCore.ServerRequest(stream: request), context: context ) return GRPCCore.StreamingServerResponse(single: response) } } // Default implementation of methods from 'ServiceProtocol'. extension Helloworld_Greeter.SimpleServiceProtocol { internal func sayHello( request: GRPCCore.ServerRequest, context: GRPCCore.ServerContext ) async throws -> GRPCCore.ServerResponse { return GRPCCore.ServerResponse( message: try await self.sayHello( request: request.message, context: context ), metadata: [:] ) } } // MARK: helloworld.Greeter (client) extension Helloworld_Greeter { /// Generated client protocol for the "helloworld.Greeter" service. /// /// You don't need to implement this protocol directly, use the generated /// implementation, ``Client``. /// /// > Source IDL Documentation: /// > /// > The greeting service definition. internal protocol ClientProtocol: Sendable { /// Call the "SayHello" method. /// /// > Source IDL Documentation: /// > /// > Sends a greeting /// /// - Parameters: /// - request: A request containing a single `Helloworld_HelloRequest` message. /// - serializer: A serializer for `Helloworld_HelloRequest` messages. /// - deserializer: A deserializer for `Helloworld_HelloReply` messages. /// - options: Options to apply to this RPC. /// - handleResponse: A closure which handles the response, the result of which is /// returned to the caller. Returning from the closure will cancel the RPC if it /// hasn't already finished. /// - Returns: The result of `handleResponse`. func sayHello( request: GRPCCore.ClientRequest, serializer: some GRPCCore.MessageSerializer, deserializer: some GRPCCore.MessageDeserializer, options: GRPCCore.CallOptions, onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result ) async throws -> Result where Result: Sendable } /// Generated client for the "helloworld.Greeter" service. /// /// The ``Client`` provides an implementation of ``ClientProtocol`` which wraps /// a `GRPCCore.GRPCCClient`. The underlying `GRPCClient` provides the long-lived /// means of communication with the remote peer. /// /// > Source IDL Documentation: /// > /// > The greeting service definition. internal struct Client: ClientProtocol { private let client: GRPCCore.GRPCClient /// Creates a new client wrapping the provided `GRPCCore.GRPCClient`. /// /// - Parameters: /// - client: A `GRPCCore.GRPCClient` providing a communication channel to the service. internal init(wrapping client: GRPCCore.GRPCClient) { self.client = client } /// Call the "SayHello" method. /// /// > Source IDL Documentation: /// > /// > Sends a greeting /// /// - Parameters: /// - request: A request containing a single `Helloworld_HelloRequest` message. /// - serializer: A serializer for `Helloworld_HelloRequest` messages. /// - deserializer: A deserializer for `Helloworld_HelloReply` messages. /// - options: Options to apply to this RPC. /// - handleResponse: A closure which handles the response, the result of which is /// returned to the caller. Returning from the closure will cancel the RPC if it /// hasn't already finished. /// - Returns: The result of `handleResponse`. internal func sayHello( request: GRPCCore.ClientRequest, serializer: some GRPCCore.MessageSerializer, deserializer: some GRPCCore.MessageDeserializer, options: GRPCCore.CallOptions = .defaults, onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in try response.message } ) async throws -> Result where Result: Sendable { try await self.client.unary( request: request, descriptor: Helloworld_Greeter.Method.SayHello.descriptor, serializer: serializer, deserializer: deserializer, options: options, onResponse: handleResponse ) } } } // Helpers providing default arguments to 'ClientProtocol' methods. extension Helloworld_Greeter.ClientProtocol { /// Call the "SayHello" method. /// /// > Source IDL Documentation: /// > /// > Sends a greeting /// /// - Parameters: /// - request: A request containing a single `Helloworld_HelloRequest` message. /// - options: Options to apply to this RPC. /// - handleResponse: A closure which handles the response, the result of which is /// returned to the caller. Returning from the closure will cancel the RPC if it /// hasn't already finished. /// - Returns: The result of `handleResponse`. internal func sayHello( request: GRPCCore.ClientRequest, options: GRPCCore.CallOptions = .defaults, onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in try response.message } ) async throws -> Result where Result: Sendable { try await self.sayHello( request: request, serializer: GRPCProtobuf.ProtobufSerializer(), deserializer: GRPCProtobuf.ProtobufDeserializer(), options: options, onResponse: handleResponse ) } } // Helpers providing sugared APIs for 'ClientProtocol' methods. extension Helloworld_Greeter.ClientProtocol { /// Call the "SayHello" method. /// /// > Source IDL Documentation: /// > /// > Sends a greeting /// /// - Parameters: /// - message: request message to send. /// - metadata: Additional metadata to send, defaults to empty. /// - options: Options to apply to this RPC, defaults to `.defaults`. /// - handleResponse: A closure which handles the response, the result of which is /// returned to the caller. Returning from the closure will cancel the RPC if it /// hasn't already finished. /// - Returns: The result of `handleResponse`. internal func sayHello( _ message: Helloworld_HelloRequest, metadata: GRPCCore.Metadata = [:], options: GRPCCore.CallOptions = .defaults, onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in try response.message } ) async throws -> Result where Result: Sendable { let request = GRPCCore.ClientRequest( message: message, metadata: metadata ) return try await self.sayHello( request: request, options: options, onResponse: handleResponse ) } }