// 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: route_guide.proto // // For information on using the generated types, please see the documentation: // https://github.com/grpc/grpc-swift import GRPCCore import GRPCProtobuf // MARK: - routeguide.RouteGuide /// Namespace containing generated types for the "routeguide.RouteGuide" service. internal enum Routeguide_RouteGuide { /// Service descriptor for the "routeguide.RouteGuide" service. internal static let descriptor = GRPCCore.ServiceDescriptor(fullyQualifiedService: "routeguide.RouteGuide") /// Namespace for method metadata. internal enum Method { /// Namespace for "GetFeature" metadata. internal enum GetFeature { /// Request type for "GetFeature". internal typealias Input = Routeguide_Point /// Response type for "GetFeature". internal typealias Output = Routeguide_Feature /// Descriptor for "GetFeature". internal static let descriptor = GRPCCore.MethodDescriptor( service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "routeguide.RouteGuide"), method: "GetFeature" ) } /// Namespace for "ListFeatures" metadata. internal enum ListFeatures { /// Request type for "ListFeatures". internal typealias Input = Routeguide_Rectangle /// Response type for "ListFeatures". internal typealias Output = Routeguide_Feature /// Descriptor for "ListFeatures". internal static let descriptor = GRPCCore.MethodDescriptor( service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "routeguide.RouteGuide"), method: "ListFeatures" ) } /// Namespace for "RecordRoute" metadata. internal enum RecordRoute { /// Request type for "RecordRoute". internal typealias Input = Routeguide_Point /// Response type for "RecordRoute". internal typealias Output = Routeguide_RouteSummary /// Descriptor for "RecordRoute". internal static let descriptor = GRPCCore.MethodDescriptor( service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "routeguide.RouteGuide"), method: "RecordRoute" ) } /// Namespace for "RouteChat" metadata. internal enum RouteChat { /// Request type for "RouteChat". internal typealias Input = Routeguide_RouteNote /// Response type for "RouteChat". internal typealias Output = Routeguide_RouteNote /// Descriptor for "RouteChat". internal static let descriptor = GRPCCore.MethodDescriptor( service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "routeguide.RouteGuide"), method: "RouteChat" ) } /// Descriptors for all methods in the "routeguide.RouteGuide" service. internal static let descriptors: [GRPCCore.MethodDescriptor] = [ GetFeature.descriptor, ListFeatures.descriptor, RecordRoute.descriptor, RouteChat.descriptor ] } } extension GRPCCore.ServiceDescriptor { /// Service descriptor for the "routeguide.RouteGuide" service. internal static let routeguide_RouteGuide = GRPCCore.ServiceDescriptor(fullyQualifiedService: "routeguide.RouteGuide") } // MARK: routeguide.RouteGuide (server) extension Routeguide_RouteGuide { /// Streaming variant of the service protocol for the "routeguide.RouteGuide" 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: /// > /// > Interface exported by the server. internal protocol StreamingServiceProtocol: GRPCCore.RegistrableRPCService { /// Handle the "GetFeature" method. /// /// > Source IDL Documentation: /// > /// > A simple RPC. /// > /// > Obtains the feature at a given position. /// > /// > A feature with an empty name is returned if there's no feature at the given /// > position. /// /// - Parameters: /// - request: A streaming request of `Routeguide_Point` 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 `Routeguide_Feature` messages. func getFeature( request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext ) async throws -> GRPCCore.StreamingServerResponse /// Handle the "ListFeatures" method. /// /// > Source IDL Documentation: /// > /// > A server-to-client streaming RPC. /// > /// > Obtains the Features available within the given Rectangle. Results are /// > streamed rather than returned at once (e.g. in a response message with a /// > repeated field), as the rectangle may cover a large area and contain a /// > huge number of features. /// /// - Parameters: /// - request: A streaming request of `Routeguide_Rectangle` 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 `Routeguide_Feature` messages. func listFeatures( request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext ) async throws -> GRPCCore.StreamingServerResponse /// Handle the "RecordRoute" method. /// /// > Source IDL Documentation: /// > /// > A client-to-server streaming RPC. /// > /// > Accepts a stream of Points on a route being traversed, returning a /// > RouteSummary when traversal is completed. /// /// - Parameters: /// - request: A streaming request of `Routeguide_Point` 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 `Routeguide_RouteSummary` messages. func recordRoute( request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext ) async throws -> GRPCCore.StreamingServerResponse /// Handle the "RouteChat" method. /// /// > Source IDL Documentation: /// > /// > A Bidirectional streaming RPC. /// > /// > Accepts a stream of RouteNotes sent while a route is being traversed, /// > while receiving other RouteNotes (e.g. from other users). /// /// - Parameters: /// - request: A streaming request of `Routeguide_RouteNote` 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 `Routeguide_RouteNote` messages. func routeChat( request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext ) async throws -> GRPCCore.StreamingServerResponse } /// Service protocol for the "routeguide.RouteGuide" 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: /// > /// > Interface exported by the server. internal protocol ServiceProtocol: Routeguide_RouteGuide.StreamingServiceProtocol { /// Handle the "GetFeature" method. /// /// > Source IDL Documentation: /// > /// > A simple RPC. /// > /// > Obtains the feature at a given position. /// > /// > A feature with an empty name is returned if there's no feature at the given /// > position. /// /// - Parameters: /// - request: A request containing a single `Routeguide_Point` 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 `Routeguide_Feature` message. func getFeature( request: GRPCCore.ServerRequest, context: GRPCCore.ServerContext ) async throws -> GRPCCore.ServerResponse /// Handle the "ListFeatures" method. /// /// > Source IDL Documentation: /// > /// > A server-to-client streaming RPC. /// > /// > Obtains the Features available within the given Rectangle. Results are /// > streamed rather than returned at once (e.g. in a response message with a /// > repeated field), as the rectangle may cover a large area and contain a /// > huge number of features. /// /// - Parameters: /// - request: A request containing a single `Routeguide_Rectangle` 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 streaming response of `Routeguide_Feature` messages. func listFeatures( request: GRPCCore.ServerRequest, context: GRPCCore.ServerContext ) async throws -> GRPCCore.StreamingServerResponse /// Handle the "RecordRoute" method. /// /// > Source IDL Documentation: /// > /// > A client-to-server streaming RPC. /// > /// > Accepts a stream of Points on a route being traversed, returning a /// > RouteSummary when traversal is completed. /// /// - Parameters: /// - request: A streaming request of `Routeguide_Point` 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 response containing a single `Routeguide_RouteSummary` message. func recordRoute( request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext ) async throws -> GRPCCore.ServerResponse /// Handle the "RouteChat" method. /// /// > Source IDL Documentation: /// > /// > A Bidirectional streaming RPC. /// > /// > Accepts a stream of RouteNotes sent while a route is being traversed, /// > while receiving other RouteNotes (e.g. from other users). /// /// - Parameters: /// - request: A streaming request of `Routeguide_RouteNote` 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 `Routeguide_RouteNote` messages. func routeChat( request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext ) async throws -> GRPCCore.StreamingServerResponse } /// Simple service protocol for the "routeguide.RouteGuide" 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: /// > /// > Interface exported by the server. internal protocol SimpleServiceProtocol: Routeguide_RouteGuide.ServiceProtocol { /// Handle the "GetFeature" method. /// /// > Source IDL Documentation: /// > /// > A simple RPC. /// > /// > Obtains the feature at a given position. /// > /// > A feature with an empty name is returned if there's no feature at the given /// > position. /// /// - Parameters: /// - request: A `Routeguide_Point` 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 `Routeguide_Feature` to respond with. func getFeature( request: Routeguide_Point, context: GRPCCore.ServerContext ) async throws -> Routeguide_Feature /// Handle the "ListFeatures" method. /// /// > Source IDL Documentation: /// > /// > A server-to-client streaming RPC. /// > /// > Obtains the Features available within the given Rectangle. Results are /// > streamed rather than returned at once (e.g. in a response message with a /// > repeated field), as the rectangle may cover a large area and contain a /// > huge number of features. /// /// - Parameters: /// - request: A `Routeguide_Rectangle` message. /// - response: A response stream of `Routeguide_Feature` 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. func listFeatures( request: Routeguide_Rectangle, response: GRPCCore.RPCWriter, context: GRPCCore.ServerContext ) async throws /// Handle the "RecordRoute" method. /// /// > Source IDL Documentation: /// > /// > A client-to-server streaming RPC. /// > /// > Accepts a stream of Points on a route being traversed, returning a /// > RouteSummary when traversal is completed. /// /// - Parameters: /// - request: A stream of `Routeguide_Point` 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 `Routeguide_RouteSummary` to respond with. func recordRoute( request: GRPCCore.RPCAsyncSequence, context: GRPCCore.ServerContext ) async throws -> Routeguide_RouteSummary /// Handle the "RouteChat" method. /// /// > Source IDL Documentation: /// > /// > A Bidirectional streaming RPC. /// > /// > Accepts a stream of RouteNotes sent while a route is being traversed, /// > while receiving other RouteNotes (e.g. from other users). /// /// - Parameters: /// - request: A stream of `Routeguide_RouteNote` messages. /// - response: A response stream of `Routeguide_RouteNote` 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. func routeChat( request: GRPCCore.RPCAsyncSequence, response: GRPCCore.RPCWriter, context: GRPCCore.ServerContext ) async throws } } // Default implementation of 'registerMethods(with:)'. extension Routeguide_RouteGuide.StreamingServiceProtocol { internal func registerMethods(with router: inout GRPCCore.RPCRouter) where Transport: GRPCCore.ServerTransport { router.registerHandler( forMethod: Routeguide_RouteGuide.Method.GetFeature.descriptor, deserializer: GRPCProtobuf.ProtobufDeserializer(), serializer: GRPCProtobuf.ProtobufSerializer(), handler: { request, context in try await self.getFeature( request: request, context: context ) } ) router.registerHandler( forMethod: Routeguide_RouteGuide.Method.ListFeatures.descriptor, deserializer: GRPCProtobuf.ProtobufDeserializer(), serializer: GRPCProtobuf.ProtobufSerializer(), handler: { request, context in try await self.listFeatures( request: request, context: context ) } ) router.registerHandler( forMethod: Routeguide_RouteGuide.Method.RecordRoute.descriptor, deserializer: GRPCProtobuf.ProtobufDeserializer(), serializer: GRPCProtobuf.ProtobufSerializer(), handler: { request, context in try await self.recordRoute( request: request, context: context ) } ) router.registerHandler( forMethod: Routeguide_RouteGuide.Method.RouteChat.descriptor, deserializer: GRPCProtobuf.ProtobufDeserializer(), serializer: GRPCProtobuf.ProtobufSerializer(), handler: { request, context in try await self.routeChat( request: request, context: context ) } ) } } // Default implementation of streaming methods from 'StreamingServiceProtocol'. extension Routeguide_RouteGuide.ServiceProtocol { internal func getFeature( request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext ) async throws -> GRPCCore.StreamingServerResponse { let response = try await self.getFeature( request: GRPCCore.ServerRequest(stream: request), context: context ) return GRPCCore.StreamingServerResponse(single: response) } internal func listFeatures( request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext ) async throws -> GRPCCore.StreamingServerResponse { let response = try await self.listFeatures( request: GRPCCore.ServerRequest(stream: request), context: context ) return response } internal func recordRoute( request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext ) async throws -> GRPCCore.StreamingServerResponse { let response = try await self.recordRoute( request: request, context: context ) return GRPCCore.StreamingServerResponse(single: response) } } // Default implementation of methods from 'ServiceProtocol'. extension Routeguide_RouteGuide.SimpleServiceProtocol { internal func getFeature( request: GRPCCore.ServerRequest, context: GRPCCore.ServerContext ) async throws -> GRPCCore.ServerResponse { return GRPCCore.ServerResponse( message: try await self.getFeature( request: request.message, context: context ), metadata: [:] ) } internal func listFeatures( request: GRPCCore.ServerRequest, context: GRPCCore.ServerContext ) async throws -> GRPCCore.StreamingServerResponse { return GRPCCore.StreamingServerResponse( metadata: [:], producer: { writer in try await self.listFeatures( request: request.message, response: writer, context: context ) return [:] } ) } internal func recordRoute( request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext ) async throws -> GRPCCore.ServerResponse { return GRPCCore.ServerResponse( message: try await self.recordRoute( request: request.messages, context: context ), metadata: [:] ) } internal func routeChat( request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext ) async throws -> GRPCCore.StreamingServerResponse { return GRPCCore.StreamingServerResponse( metadata: [:], producer: { writer in try await self.routeChat( request: request.messages, response: writer, context: context ) return [:] } ) } } // MARK: routeguide.RouteGuide (client) extension Routeguide_RouteGuide { /// Generated client protocol for the "routeguide.RouteGuide" service. /// /// You don't need to implement this protocol directly, use the generated /// implementation, ``Client``. /// /// > Source IDL Documentation: /// > /// > Interface exported by the server. internal protocol ClientProtocol: Sendable { /// Call the "GetFeature" method. /// /// > Source IDL Documentation: /// > /// > A simple RPC. /// > /// > Obtains the feature at a given position. /// > /// > A feature with an empty name is returned if there's no feature at the given /// > position. /// /// - Parameters: /// - request: A request containing a single `Routeguide_Point` message. /// - serializer: A serializer for `Routeguide_Point` messages. /// - deserializer: A deserializer for `Routeguide_Feature` 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 getFeature( 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 /// Call the "ListFeatures" method. /// /// > Source IDL Documentation: /// > /// > A server-to-client streaming RPC. /// > /// > Obtains the Features available within the given Rectangle. Results are /// > streamed rather than returned at once (e.g. in a response message with a /// > repeated field), as the rectangle may cover a large area and contain a /// > huge number of features. /// /// - Parameters: /// - request: A request containing a single `Routeguide_Rectangle` message. /// - serializer: A serializer for `Routeguide_Rectangle` messages. /// - deserializer: A deserializer for `Routeguide_Feature` 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 listFeatures( request: GRPCCore.ClientRequest, serializer: some GRPCCore.MessageSerializer, deserializer: some GRPCCore.MessageDeserializer, options: GRPCCore.CallOptions, onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> Result ) async throws -> Result where Result: Sendable /// Call the "RecordRoute" method. /// /// > Source IDL Documentation: /// > /// > A client-to-server streaming RPC. /// > /// > Accepts a stream of Points on a route being traversed, returning a /// > RouteSummary when traversal is completed. /// /// - Parameters: /// - request: A streaming request producing `Routeguide_Point` messages. /// - serializer: A serializer for `Routeguide_Point` messages. /// - deserializer: A deserializer for `Routeguide_RouteSummary` 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 recordRoute( request: GRPCCore.StreamingClientRequest, 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 /// Call the "RouteChat" method. /// /// > Source IDL Documentation: /// > /// > A Bidirectional streaming RPC. /// > /// > Accepts a stream of RouteNotes sent while a route is being traversed, /// > while receiving other RouteNotes (e.g. from other users). /// /// - Parameters: /// - request: A streaming request producing `Routeguide_RouteNote` messages. /// - serializer: A serializer for `Routeguide_RouteNote` messages. /// - deserializer: A deserializer for `Routeguide_RouteNote` 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 routeChat( request: GRPCCore.StreamingClientRequest, serializer: some GRPCCore.MessageSerializer, deserializer: some GRPCCore.MessageDeserializer, options: GRPCCore.CallOptions, onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> Result ) async throws -> Result where Result: Sendable } /// Generated client for the "routeguide.RouteGuide" 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: /// > /// > Interface exported by the server. internal struct Client: ClientProtocol where Transport: GRPCCore.ClientTransport { 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 "GetFeature" method. /// /// > Source IDL Documentation: /// > /// > A simple RPC. /// > /// > Obtains the feature at a given position. /// > /// > A feature with an empty name is returned if there's no feature at the given /// > position. /// /// - Parameters: /// - request: A request containing a single `Routeguide_Point` message. /// - serializer: A serializer for `Routeguide_Point` messages. /// - deserializer: A deserializer for `Routeguide_Feature` 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 getFeature( 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: Routeguide_RouteGuide.Method.GetFeature.descriptor, serializer: serializer, deserializer: deserializer, options: options, onResponse: handleResponse ) } /// Call the "ListFeatures" method. /// /// > Source IDL Documentation: /// > /// > A server-to-client streaming RPC. /// > /// > Obtains the Features available within the given Rectangle. Results are /// > streamed rather than returned at once (e.g. in a response message with a /// > repeated field), as the rectangle may cover a large area and contain a /// > huge number of features. /// /// - Parameters: /// - request: A request containing a single `Routeguide_Rectangle` message. /// - serializer: A serializer for `Routeguide_Rectangle` messages. /// - deserializer: A deserializer for `Routeguide_Feature` 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 listFeatures( request: GRPCCore.ClientRequest, serializer: some GRPCCore.MessageSerializer, deserializer: some GRPCCore.MessageDeserializer, options: GRPCCore.CallOptions = .defaults, onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> Result ) async throws -> Result where Result: Sendable { try await self.client.serverStreaming( request: request, descriptor: Routeguide_RouteGuide.Method.ListFeatures.descriptor, serializer: serializer, deserializer: deserializer, options: options, onResponse: handleResponse ) } /// Call the "RecordRoute" method. /// /// > Source IDL Documentation: /// > /// > A client-to-server streaming RPC. /// > /// > Accepts a stream of Points on a route being traversed, returning a /// > RouteSummary when traversal is completed. /// /// - Parameters: /// - request: A streaming request producing `Routeguide_Point` messages. /// - serializer: A serializer for `Routeguide_Point` messages. /// - deserializer: A deserializer for `Routeguide_RouteSummary` 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 recordRoute( request: GRPCCore.StreamingClientRequest, 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.clientStreaming( request: request, descriptor: Routeguide_RouteGuide.Method.RecordRoute.descriptor, serializer: serializer, deserializer: deserializer, options: options, onResponse: handleResponse ) } /// Call the "RouteChat" method. /// /// > Source IDL Documentation: /// > /// > A Bidirectional streaming RPC. /// > /// > Accepts a stream of RouteNotes sent while a route is being traversed, /// > while receiving other RouteNotes (e.g. from other users). /// /// - Parameters: /// - request: A streaming request producing `Routeguide_RouteNote` messages. /// - serializer: A serializer for `Routeguide_RouteNote` messages. /// - deserializer: A deserializer for `Routeguide_RouteNote` 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 routeChat( request: GRPCCore.StreamingClientRequest, serializer: some GRPCCore.MessageSerializer, deserializer: some GRPCCore.MessageDeserializer, options: GRPCCore.CallOptions = .defaults, onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> Result ) async throws -> Result where Result: Sendable { try await self.client.bidirectionalStreaming( request: request, descriptor: Routeguide_RouteGuide.Method.RouteChat.descriptor, serializer: serializer, deserializer: deserializer, options: options, onResponse: handleResponse ) } } } // Helpers providing default arguments to 'ClientProtocol' methods. extension Routeguide_RouteGuide.ClientProtocol { /// Call the "GetFeature" method. /// /// > Source IDL Documentation: /// > /// > A simple RPC. /// > /// > Obtains the feature at a given position. /// > /// > A feature with an empty name is returned if there's no feature at the given /// > position. /// /// - Parameters: /// - request: A request containing a single `Routeguide_Point` 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 getFeature( 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.getFeature( request: request, serializer: GRPCProtobuf.ProtobufSerializer(), deserializer: GRPCProtobuf.ProtobufDeserializer(), options: options, onResponse: handleResponse ) } /// Call the "ListFeatures" method. /// /// > Source IDL Documentation: /// > /// > A server-to-client streaming RPC. /// > /// > Obtains the Features available within the given Rectangle. Results are /// > streamed rather than returned at once (e.g. in a response message with a /// > repeated field), as the rectangle may cover a large area and contain a /// > huge number of features. /// /// - Parameters: /// - request: A request containing a single `Routeguide_Rectangle` 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 listFeatures( request: GRPCCore.ClientRequest, options: GRPCCore.CallOptions = .defaults, onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> Result ) async throws -> Result where Result: Sendable { try await self.listFeatures( request: request, serializer: GRPCProtobuf.ProtobufSerializer(), deserializer: GRPCProtobuf.ProtobufDeserializer(), options: options, onResponse: handleResponse ) } /// Call the "RecordRoute" method. /// /// > Source IDL Documentation: /// > /// > A client-to-server streaming RPC. /// > /// > Accepts a stream of Points on a route being traversed, returning a /// > RouteSummary when traversal is completed. /// /// - Parameters: /// - request: A streaming request producing `Routeguide_Point` 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 recordRoute( request: GRPCCore.StreamingClientRequest, 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.recordRoute( request: request, serializer: GRPCProtobuf.ProtobufSerializer(), deserializer: GRPCProtobuf.ProtobufDeserializer(), options: options, onResponse: handleResponse ) } /// Call the "RouteChat" method. /// /// > Source IDL Documentation: /// > /// > A Bidirectional streaming RPC. /// > /// > Accepts a stream of RouteNotes sent while a route is being traversed, /// > while receiving other RouteNotes (e.g. from other users). /// /// - Parameters: /// - request: A streaming request producing `Routeguide_RouteNote` 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 routeChat( request: GRPCCore.StreamingClientRequest, options: GRPCCore.CallOptions = .defaults, onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> Result ) async throws -> Result where Result: Sendable { try await self.routeChat( request: request, serializer: GRPCProtobuf.ProtobufSerializer(), deserializer: GRPCProtobuf.ProtobufDeserializer(), options: options, onResponse: handleResponse ) } } // Helpers providing sugared APIs for 'ClientProtocol' methods. extension Routeguide_RouteGuide.ClientProtocol { /// Call the "GetFeature" method. /// /// > Source IDL Documentation: /// > /// > A simple RPC. /// > /// > Obtains the feature at a given position. /// > /// > A feature with an empty name is returned if there's no feature at the given /// > position. /// /// - 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 getFeature( _ message: Routeguide_Point, 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.getFeature( request: request, options: options, onResponse: handleResponse ) } /// Call the "ListFeatures" method. /// /// > Source IDL Documentation: /// > /// > A server-to-client streaming RPC. /// > /// > Obtains the Features available within the given Rectangle. Results are /// > streamed rather than returned at once (e.g. in a response message with a /// > repeated field), as the rectangle may cover a large area and contain a /// > huge number of features. /// /// - 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 listFeatures( _ message: Routeguide_Rectangle, metadata: GRPCCore.Metadata = [:], options: GRPCCore.CallOptions = .defaults, onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> Result ) async throws -> Result where Result: Sendable { let request = GRPCCore.ClientRequest( message: message, metadata: metadata ) return try await self.listFeatures( request: request, options: options, onResponse: handleResponse ) } /// Call the "RecordRoute" method. /// /// > Source IDL Documentation: /// > /// > A client-to-server streaming RPC. /// > /// > Accepts a stream of Points on a route being traversed, returning a /// > RouteSummary when traversal is completed. /// /// - Parameters: /// - metadata: Additional metadata to send, defaults to empty. /// - options: Options to apply to this RPC, defaults to `.defaults`. /// - producer: A closure producing request messages to send to the server. The request /// stream is closed when the closure returns. /// - 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 recordRoute( metadata: GRPCCore.Metadata = [:], options: GRPCCore.CallOptions = .defaults, requestProducer producer: @Sendable @escaping (GRPCCore.RPCWriter) async throws -> Void, onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in try response.message } ) async throws -> Result where Result: Sendable { let request = GRPCCore.StreamingClientRequest( metadata: metadata, producer: producer ) return try await self.recordRoute( request: request, options: options, onResponse: handleResponse ) } /// Call the "RouteChat" method. /// /// > Source IDL Documentation: /// > /// > A Bidirectional streaming RPC. /// > /// > Accepts a stream of RouteNotes sent while a route is being traversed, /// > while receiving other RouteNotes (e.g. from other users). /// /// - Parameters: /// - metadata: Additional metadata to send, defaults to empty. /// - options: Options to apply to this RPC, defaults to `.defaults`. /// - producer: A closure producing request messages to send to the server. The request /// stream is closed when the closure returns. /// - 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 routeChat( metadata: GRPCCore.Metadata = [:], options: GRPCCore.CallOptions = .defaults, requestProducer producer: @Sendable @escaping (GRPCCore.RPCWriter) async throws -> Void, onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> Result ) async throws -> Result where Result: Sendable { let request = GRPCCore.StreamingClientRequest( metadata: metadata, producer: producer ) return try await self.routeChat( request: request, options: options, onResponse: handleResponse ) } }