route_guide.grpc.swift 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126
  1. // Copyright 2015 gRPC authors.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // DO NOT EDIT.
  15. // swift-format-ignore-file
  16. //
  17. // Generated by the gRPC Swift generator plugin for the protocol buffer compiler.
  18. // Source: route_guide.proto
  19. //
  20. // For information on using the generated types, please see the documentation:
  21. // https://github.com/grpc/grpc-swift
  22. import GRPCCore
  23. import GRPCProtobuf
  24. // MARK: - routeguide.RouteGuide
  25. /// Namespace containing generated types for the "routeguide.RouteGuide" service.
  26. internal enum Routeguide_RouteGuide {
  27. /// Service descriptor for the "routeguide.RouteGuide" service.
  28. internal static let descriptor = GRPCCore.ServiceDescriptor(fullyQualifiedService: "routeguide.RouteGuide")
  29. /// Namespace for method metadata.
  30. internal enum Method {
  31. /// Namespace for "GetFeature" metadata.
  32. internal enum GetFeature {
  33. /// Request type for "GetFeature".
  34. internal typealias Input = Routeguide_Point
  35. /// Response type for "GetFeature".
  36. internal typealias Output = Routeguide_Feature
  37. /// Descriptor for "GetFeature".
  38. internal static let descriptor = GRPCCore.MethodDescriptor(
  39. service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "routeguide.RouteGuide"),
  40. method: "GetFeature"
  41. )
  42. }
  43. /// Namespace for "ListFeatures" metadata.
  44. internal enum ListFeatures {
  45. /// Request type for "ListFeatures".
  46. internal typealias Input = Routeguide_Rectangle
  47. /// Response type for "ListFeatures".
  48. internal typealias Output = Routeguide_Feature
  49. /// Descriptor for "ListFeatures".
  50. internal static let descriptor = GRPCCore.MethodDescriptor(
  51. service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "routeguide.RouteGuide"),
  52. method: "ListFeatures"
  53. )
  54. }
  55. /// Namespace for "RecordRoute" metadata.
  56. internal enum RecordRoute {
  57. /// Request type for "RecordRoute".
  58. internal typealias Input = Routeguide_Point
  59. /// Response type for "RecordRoute".
  60. internal typealias Output = Routeguide_RouteSummary
  61. /// Descriptor for "RecordRoute".
  62. internal static let descriptor = GRPCCore.MethodDescriptor(
  63. service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "routeguide.RouteGuide"),
  64. method: "RecordRoute"
  65. )
  66. }
  67. /// Namespace for "RouteChat" metadata.
  68. internal enum RouteChat {
  69. /// Request type for "RouteChat".
  70. internal typealias Input = Routeguide_RouteNote
  71. /// Response type for "RouteChat".
  72. internal typealias Output = Routeguide_RouteNote
  73. /// Descriptor for "RouteChat".
  74. internal static let descriptor = GRPCCore.MethodDescriptor(
  75. service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "routeguide.RouteGuide"),
  76. method: "RouteChat"
  77. )
  78. }
  79. /// Descriptors for all methods in the "routeguide.RouteGuide" service.
  80. internal static let descriptors: [GRPCCore.MethodDescriptor] = [
  81. GetFeature.descriptor,
  82. ListFeatures.descriptor,
  83. RecordRoute.descriptor,
  84. RouteChat.descriptor
  85. ]
  86. }
  87. }
  88. extension GRPCCore.ServiceDescriptor {
  89. /// Service descriptor for the "routeguide.RouteGuide" service.
  90. internal static let routeguide_RouteGuide = GRPCCore.ServiceDescriptor(fullyQualifiedService: "routeguide.RouteGuide")
  91. }
  92. // MARK: routeguide.RouteGuide (server)
  93. extension Routeguide_RouteGuide {
  94. /// Streaming variant of the service protocol for the "routeguide.RouteGuide" service.
  95. ///
  96. /// This protocol is the lowest-level of the service protocols generated for this service
  97. /// giving you the most flexibility over the implementation of your service. This comes at
  98. /// the cost of more verbose and less strict APIs. Each RPC requires you to implement it in
  99. /// terms of a request stream and response stream. Where only a single request or response
  100. /// message is expected, you are responsible for enforcing this invariant is maintained.
  101. ///
  102. /// Where possible, prefer using the stricter, less-verbose ``ServiceProtocol``
  103. /// or ``SimpleServiceProtocol`` instead.
  104. ///
  105. /// > Source IDL Documentation:
  106. /// >
  107. /// > Interface exported by the server.
  108. internal protocol StreamingServiceProtocol: GRPCCore.RegistrableRPCService {
  109. /// Handle the "GetFeature" method.
  110. ///
  111. /// > Source IDL Documentation:
  112. /// >
  113. /// > A simple RPC.
  114. /// >
  115. /// > Obtains the feature at a given position.
  116. /// >
  117. /// > A feature with an empty name is returned if there's no feature at the given
  118. /// > position.
  119. ///
  120. /// - Parameters:
  121. /// - request: A streaming request of `Routeguide_Point` messages.
  122. /// - context: Context providing information about the RPC.
  123. /// - Throws: Any error which occurred during the processing of the request. Thrown errors
  124. /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
  125. /// to an internal error.
  126. /// - Returns: A streaming response of `Routeguide_Feature` messages.
  127. func getFeature(
  128. request: GRPCCore.StreamingServerRequest<Routeguide_Point>,
  129. context: GRPCCore.ServerContext
  130. ) async throws -> GRPCCore.StreamingServerResponse<Routeguide_Feature>
  131. /// Handle the "ListFeatures" method.
  132. ///
  133. /// > Source IDL Documentation:
  134. /// >
  135. /// > A server-to-client streaming RPC.
  136. /// >
  137. /// > Obtains the Features available within the given Rectangle. Results are
  138. /// > streamed rather than returned at once (e.g. in a response message with a
  139. /// > repeated field), as the rectangle may cover a large area and contain a
  140. /// > huge number of features.
  141. ///
  142. /// - Parameters:
  143. /// - request: A streaming request of `Routeguide_Rectangle` messages.
  144. /// - context: Context providing information about the RPC.
  145. /// - Throws: Any error which occurred during the processing of the request. Thrown errors
  146. /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
  147. /// to an internal error.
  148. /// - Returns: A streaming response of `Routeguide_Feature` messages.
  149. func listFeatures(
  150. request: GRPCCore.StreamingServerRequest<Routeguide_Rectangle>,
  151. context: GRPCCore.ServerContext
  152. ) async throws -> GRPCCore.StreamingServerResponse<Routeguide_Feature>
  153. /// Handle the "RecordRoute" method.
  154. ///
  155. /// > Source IDL Documentation:
  156. /// >
  157. /// > A client-to-server streaming RPC.
  158. /// >
  159. /// > Accepts a stream of Points on a route being traversed, returning a
  160. /// > RouteSummary when traversal is completed.
  161. ///
  162. /// - Parameters:
  163. /// - request: A streaming request of `Routeguide_Point` messages.
  164. /// - context: Context providing information about the RPC.
  165. /// - Throws: Any error which occurred during the processing of the request. Thrown errors
  166. /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
  167. /// to an internal error.
  168. /// - Returns: A streaming response of `Routeguide_RouteSummary` messages.
  169. func recordRoute(
  170. request: GRPCCore.StreamingServerRequest<Routeguide_Point>,
  171. context: GRPCCore.ServerContext
  172. ) async throws -> GRPCCore.StreamingServerResponse<Routeguide_RouteSummary>
  173. /// Handle the "RouteChat" method.
  174. ///
  175. /// > Source IDL Documentation:
  176. /// >
  177. /// > A Bidirectional streaming RPC.
  178. /// >
  179. /// > Accepts a stream of RouteNotes sent while a route is being traversed,
  180. /// > while receiving other RouteNotes (e.g. from other users).
  181. ///
  182. /// - Parameters:
  183. /// - request: A streaming request of `Routeguide_RouteNote` messages.
  184. /// - context: Context providing information about the RPC.
  185. /// - Throws: Any error which occurred during the processing of the request. Thrown errors
  186. /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
  187. /// to an internal error.
  188. /// - Returns: A streaming response of `Routeguide_RouteNote` messages.
  189. func routeChat(
  190. request: GRPCCore.StreamingServerRequest<Routeguide_RouteNote>,
  191. context: GRPCCore.ServerContext
  192. ) async throws -> GRPCCore.StreamingServerResponse<Routeguide_RouteNote>
  193. }
  194. /// Service protocol for the "routeguide.RouteGuide" service.
  195. ///
  196. /// This protocol is higher level than ``StreamingServiceProtocol`` but lower level than
  197. /// the ``SimpleServiceProtocol``, it provides access to request and response metadata and
  198. /// trailing response metadata. If you don't need these then consider using
  199. /// the ``SimpleServiceProtocol``. If you need fine grained control over your RPCs then
  200. /// use ``StreamingServiceProtocol``.
  201. ///
  202. /// > Source IDL Documentation:
  203. /// >
  204. /// > Interface exported by the server.
  205. internal protocol ServiceProtocol: Routeguide_RouteGuide.StreamingServiceProtocol {
  206. /// Handle the "GetFeature" method.
  207. ///
  208. /// > Source IDL Documentation:
  209. /// >
  210. /// > A simple RPC.
  211. /// >
  212. /// > Obtains the feature at a given position.
  213. /// >
  214. /// > A feature with an empty name is returned if there's no feature at the given
  215. /// > position.
  216. ///
  217. /// - Parameters:
  218. /// - request: A request containing a single `Routeguide_Point` message.
  219. /// - context: Context providing information about the RPC.
  220. /// - Throws: Any error which occurred during the processing of the request. Thrown errors
  221. /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
  222. /// to an internal error.
  223. /// - Returns: A response containing a single `Routeguide_Feature` message.
  224. func getFeature(
  225. request: GRPCCore.ServerRequest<Routeguide_Point>,
  226. context: GRPCCore.ServerContext
  227. ) async throws -> GRPCCore.ServerResponse<Routeguide_Feature>
  228. /// Handle the "ListFeatures" method.
  229. ///
  230. /// > Source IDL Documentation:
  231. /// >
  232. /// > A server-to-client streaming RPC.
  233. /// >
  234. /// > Obtains the Features available within the given Rectangle. Results are
  235. /// > streamed rather than returned at once (e.g. in a response message with a
  236. /// > repeated field), as the rectangle may cover a large area and contain a
  237. /// > huge number of features.
  238. ///
  239. /// - Parameters:
  240. /// - request: A request containing a single `Routeguide_Rectangle` message.
  241. /// - context: Context providing information about the RPC.
  242. /// - Throws: Any error which occurred during the processing of the request. Thrown errors
  243. /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
  244. /// to an internal error.
  245. /// - Returns: A streaming response of `Routeguide_Feature` messages.
  246. func listFeatures(
  247. request: GRPCCore.ServerRequest<Routeguide_Rectangle>,
  248. context: GRPCCore.ServerContext
  249. ) async throws -> GRPCCore.StreamingServerResponse<Routeguide_Feature>
  250. /// Handle the "RecordRoute" method.
  251. ///
  252. /// > Source IDL Documentation:
  253. /// >
  254. /// > A client-to-server streaming RPC.
  255. /// >
  256. /// > Accepts a stream of Points on a route being traversed, returning a
  257. /// > RouteSummary when traversal is completed.
  258. ///
  259. /// - Parameters:
  260. /// - request: A streaming request of `Routeguide_Point` messages.
  261. /// - context: Context providing information about the RPC.
  262. /// - Throws: Any error which occurred during the processing of the request. Thrown errors
  263. /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
  264. /// to an internal error.
  265. /// - Returns: A response containing a single `Routeguide_RouteSummary` message.
  266. func recordRoute(
  267. request: GRPCCore.StreamingServerRequest<Routeguide_Point>,
  268. context: GRPCCore.ServerContext
  269. ) async throws -> GRPCCore.ServerResponse<Routeguide_RouteSummary>
  270. /// Handle the "RouteChat" method.
  271. ///
  272. /// > Source IDL Documentation:
  273. /// >
  274. /// > A Bidirectional streaming RPC.
  275. /// >
  276. /// > Accepts a stream of RouteNotes sent while a route is being traversed,
  277. /// > while receiving other RouteNotes (e.g. from other users).
  278. ///
  279. /// - Parameters:
  280. /// - request: A streaming request of `Routeguide_RouteNote` messages.
  281. /// - context: Context providing information about the RPC.
  282. /// - Throws: Any error which occurred during the processing of the request. Thrown errors
  283. /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
  284. /// to an internal error.
  285. /// - Returns: A streaming response of `Routeguide_RouteNote` messages.
  286. func routeChat(
  287. request: GRPCCore.StreamingServerRequest<Routeguide_RouteNote>,
  288. context: GRPCCore.ServerContext
  289. ) async throws -> GRPCCore.StreamingServerResponse<Routeguide_RouteNote>
  290. }
  291. /// Simple service protocol for the "routeguide.RouteGuide" service.
  292. ///
  293. /// This is the highest level protocol for the service. The API is the easiest to use but
  294. /// doesn't provide access to request or response metadata. If you need access to these
  295. /// then use ``ServiceProtocol`` instead.
  296. ///
  297. /// > Source IDL Documentation:
  298. /// >
  299. /// > Interface exported by the server.
  300. internal protocol SimpleServiceProtocol: Routeguide_RouteGuide.ServiceProtocol {
  301. /// Handle the "GetFeature" method.
  302. ///
  303. /// > Source IDL Documentation:
  304. /// >
  305. /// > A simple RPC.
  306. /// >
  307. /// > Obtains the feature at a given position.
  308. /// >
  309. /// > A feature with an empty name is returned if there's no feature at the given
  310. /// > position.
  311. ///
  312. /// - Parameters:
  313. /// - request: A `Routeguide_Point` message.
  314. /// - context: Context providing information about the RPC.
  315. /// - Throws: Any error which occurred during the processing of the request. Thrown errors
  316. /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
  317. /// to an internal error.
  318. /// - Returns: A `Routeguide_Feature` to respond with.
  319. func getFeature(
  320. request: Routeguide_Point,
  321. context: GRPCCore.ServerContext
  322. ) async throws -> Routeguide_Feature
  323. /// Handle the "ListFeatures" method.
  324. ///
  325. /// > Source IDL Documentation:
  326. /// >
  327. /// > A server-to-client streaming RPC.
  328. /// >
  329. /// > Obtains the Features available within the given Rectangle. Results are
  330. /// > streamed rather than returned at once (e.g. in a response message with a
  331. /// > repeated field), as the rectangle may cover a large area and contain a
  332. /// > huge number of features.
  333. ///
  334. /// - Parameters:
  335. /// - request: A `Routeguide_Rectangle` message.
  336. /// - response: A response stream of `Routeguide_Feature` messages.
  337. /// - context: Context providing information about the RPC.
  338. /// - Throws: Any error which occurred during the processing of the request. Thrown errors
  339. /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
  340. /// to an internal error.
  341. func listFeatures(
  342. request: Routeguide_Rectangle,
  343. response: GRPCCore.RPCWriter<Routeguide_Feature>,
  344. context: GRPCCore.ServerContext
  345. ) async throws
  346. /// Handle the "RecordRoute" method.
  347. ///
  348. /// > Source IDL Documentation:
  349. /// >
  350. /// > A client-to-server streaming RPC.
  351. /// >
  352. /// > Accepts a stream of Points on a route being traversed, returning a
  353. /// > RouteSummary when traversal is completed.
  354. ///
  355. /// - Parameters:
  356. /// - request: A stream of `Routeguide_Point` messages.
  357. /// - context: Context providing information about the RPC.
  358. /// - Throws: Any error which occurred during the processing of the request. Thrown errors
  359. /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
  360. /// to an internal error.
  361. /// - Returns: A `Routeguide_RouteSummary` to respond with.
  362. func recordRoute(
  363. request: GRPCCore.RPCAsyncSequence<Routeguide_Point, any Swift.Error>,
  364. context: GRPCCore.ServerContext
  365. ) async throws -> Routeguide_RouteSummary
  366. /// Handle the "RouteChat" method.
  367. ///
  368. /// > Source IDL Documentation:
  369. /// >
  370. /// > A Bidirectional streaming RPC.
  371. /// >
  372. /// > Accepts a stream of RouteNotes sent while a route is being traversed,
  373. /// > while receiving other RouteNotes (e.g. from other users).
  374. ///
  375. /// - Parameters:
  376. /// - request: A stream of `Routeguide_RouteNote` messages.
  377. /// - response: A response stream of `Routeguide_RouteNote` messages.
  378. /// - context: Context providing information about the RPC.
  379. /// - Throws: Any error which occurred during the processing of the request. Thrown errors
  380. /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted
  381. /// to an internal error.
  382. func routeChat(
  383. request: GRPCCore.RPCAsyncSequence<Routeguide_RouteNote, any Swift.Error>,
  384. response: GRPCCore.RPCWriter<Routeguide_RouteNote>,
  385. context: GRPCCore.ServerContext
  386. ) async throws
  387. }
  388. }
  389. // Default implementation of 'registerMethods(with:)'.
  390. extension Routeguide_RouteGuide.StreamingServiceProtocol {
  391. internal func registerMethods<Transport>(with router: inout GRPCCore.RPCRouter<Transport>) where Transport: GRPCCore.ServerTransport {
  392. router.registerHandler(
  393. forMethod: Routeguide_RouteGuide.Method.GetFeature.descriptor,
  394. deserializer: GRPCProtobuf.ProtobufDeserializer<Routeguide_Point>(),
  395. serializer: GRPCProtobuf.ProtobufSerializer<Routeguide_Feature>(),
  396. handler: { request, context in
  397. try await self.getFeature(
  398. request: request,
  399. context: context
  400. )
  401. }
  402. )
  403. router.registerHandler(
  404. forMethod: Routeguide_RouteGuide.Method.ListFeatures.descriptor,
  405. deserializer: GRPCProtobuf.ProtobufDeserializer<Routeguide_Rectangle>(),
  406. serializer: GRPCProtobuf.ProtobufSerializer<Routeguide_Feature>(),
  407. handler: { request, context in
  408. try await self.listFeatures(
  409. request: request,
  410. context: context
  411. )
  412. }
  413. )
  414. router.registerHandler(
  415. forMethod: Routeguide_RouteGuide.Method.RecordRoute.descriptor,
  416. deserializer: GRPCProtobuf.ProtobufDeserializer<Routeguide_Point>(),
  417. serializer: GRPCProtobuf.ProtobufSerializer<Routeguide_RouteSummary>(),
  418. handler: { request, context in
  419. try await self.recordRoute(
  420. request: request,
  421. context: context
  422. )
  423. }
  424. )
  425. router.registerHandler(
  426. forMethod: Routeguide_RouteGuide.Method.RouteChat.descriptor,
  427. deserializer: GRPCProtobuf.ProtobufDeserializer<Routeguide_RouteNote>(),
  428. serializer: GRPCProtobuf.ProtobufSerializer<Routeguide_RouteNote>(),
  429. handler: { request, context in
  430. try await self.routeChat(
  431. request: request,
  432. context: context
  433. )
  434. }
  435. )
  436. }
  437. }
  438. // Default implementation of streaming methods from 'StreamingServiceProtocol'.
  439. extension Routeguide_RouteGuide.ServiceProtocol {
  440. internal func getFeature(
  441. request: GRPCCore.StreamingServerRequest<Routeguide_Point>,
  442. context: GRPCCore.ServerContext
  443. ) async throws -> GRPCCore.StreamingServerResponse<Routeguide_Feature> {
  444. let response = try await self.getFeature(
  445. request: GRPCCore.ServerRequest(stream: request),
  446. context: context
  447. )
  448. return GRPCCore.StreamingServerResponse(single: response)
  449. }
  450. internal func listFeatures(
  451. request: GRPCCore.StreamingServerRequest<Routeguide_Rectangle>,
  452. context: GRPCCore.ServerContext
  453. ) async throws -> GRPCCore.StreamingServerResponse<Routeguide_Feature> {
  454. let response = try await self.listFeatures(
  455. request: GRPCCore.ServerRequest(stream: request),
  456. context: context
  457. )
  458. return response
  459. }
  460. internal func recordRoute(
  461. request: GRPCCore.StreamingServerRequest<Routeguide_Point>,
  462. context: GRPCCore.ServerContext
  463. ) async throws -> GRPCCore.StreamingServerResponse<Routeguide_RouteSummary> {
  464. let response = try await self.recordRoute(
  465. request: request,
  466. context: context
  467. )
  468. return GRPCCore.StreamingServerResponse(single: response)
  469. }
  470. }
  471. // Default implementation of methods from 'ServiceProtocol'.
  472. extension Routeguide_RouteGuide.SimpleServiceProtocol {
  473. internal func getFeature(
  474. request: GRPCCore.ServerRequest<Routeguide_Point>,
  475. context: GRPCCore.ServerContext
  476. ) async throws -> GRPCCore.ServerResponse<Routeguide_Feature> {
  477. return GRPCCore.ServerResponse<Routeguide_Feature>(
  478. message: try await self.getFeature(
  479. request: request.message,
  480. context: context
  481. ),
  482. metadata: [:]
  483. )
  484. }
  485. internal func listFeatures(
  486. request: GRPCCore.ServerRequest<Routeguide_Rectangle>,
  487. context: GRPCCore.ServerContext
  488. ) async throws -> GRPCCore.StreamingServerResponse<Routeguide_Feature> {
  489. return GRPCCore.StreamingServerResponse<Routeguide_Feature>(
  490. metadata: [:],
  491. producer: { writer in
  492. try await self.listFeatures(
  493. request: request.message,
  494. response: writer,
  495. context: context
  496. )
  497. return [:]
  498. }
  499. )
  500. }
  501. internal func recordRoute(
  502. request: GRPCCore.StreamingServerRequest<Routeguide_Point>,
  503. context: GRPCCore.ServerContext
  504. ) async throws -> GRPCCore.ServerResponse<Routeguide_RouteSummary> {
  505. return GRPCCore.ServerResponse<Routeguide_RouteSummary>(
  506. message: try await self.recordRoute(
  507. request: request.messages,
  508. context: context
  509. ),
  510. metadata: [:]
  511. )
  512. }
  513. internal func routeChat(
  514. request: GRPCCore.StreamingServerRequest<Routeguide_RouteNote>,
  515. context: GRPCCore.ServerContext
  516. ) async throws -> GRPCCore.StreamingServerResponse<Routeguide_RouteNote> {
  517. return GRPCCore.StreamingServerResponse<Routeguide_RouteNote>(
  518. metadata: [:],
  519. producer: { writer in
  520. try await self.routeChat(
  521. request: request.messages,
  522. response: writer,
  523. context: context
  524. )
  525. return [:]
  526. }
  527. )
  528. }
  529. }
  530. // MARK: routeguide.RouteGuide (client)
  531. extension Routeguide_RouteGuide {
  532. /// Generated client protocol for the "routeguide.RouteGuide" service.
  533. ///
  534. /// You don't need to implement this protocol directly, use the generated
  535. /// implementation, ``Client``.
  536. ///
  537. /// > Source IDL Documentation:
  538. /// >
  539. /// > Interface exported by the server.
  540. internal protocol ClientProtocol: Sendable {
  541. /// Call the "GetFeature" method.
  542. ///
  543. /// > Source IDL Documentation:
  544. /// >
  545. /// > A simple RPC.
  546. /// >
  547. /// > Obtains the feature at a given position.
  548. /// >
  549. /// > A feature with an empty name is returned if there's no feature at the given
  550. /// > position.
  551. ///
  552. /// - Parameters:
  553. /// - request: A request containing a single `Routeguide_Point` message.
  554. /// - serializer: A serializer for `Routeguide_Point` messages.
  555. /// - deserializer: A deserializer for `Routeguide_Feature` messages.
  556. /// - options: Options to apply to this RPC.
  557. /// - handleResponse: A closure which handles the response, the result of which is
  558. /// returned to the caller. Returning from the closure will cancel the RPC if it
  559. /// hasn't already finished.
  560. /// - Returns: The result of `handleResponse`.
  561. func getFeature<Result>(
  562. request: GRPCCore.ClientRequest<Routeguide_Point>,
  563. serializer: some GRPCCore.MessageSerializer<Routeguide_Point>,
  564. deserializer: some GRPCCore.MessageDeserializer<Routeguide_Feature>,
  565. options: GRPCCore.CallOptions,
  566. onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<Routeguide_Feature>) async throws -> Result
  567. ) async throws -> Result where Result: Sendable
  568. /// Call the "ListFeatures" method.
  569. ///
  570. /// > Source IDL Documentation:
  571. /// >
  572. /// > A server-to-client streaming RPC.
  573. /// >
  574. /// > Obtains the Features available within the given Rectangle. Results are
  575. /// > streamed rather than returned at once (e.g. in a response message with a
  576. /// > repeated field), as the rectangle may cover a large area and contain a
  577. /// > huge number of features.
  578. ///
  579. /// - Parameters:
  580. /// - request: A request containing a single `Routeguide_Rectangle` message.
  581. /// - serializer: A serializer for `Routeguide_Rectangle` messages.
  582. /// - deserializer: A deserializer for `Routeguide_Feature` messages.
  583. /// - options: Options to apply to this RPC.
  584. /// - handleResponse: A closure which handles the response, the result of which is
  585. /// returned to the caller. Returning from the closure will cancel the RPC if it
  586. /// hasn't already finished.
  587. /// - Returns: The result of `handleResponse`.
  588. func listFeatures<Result>(
  589. request: GRPCCore.ClientRequest<Routeguide_Rectangle>,
  590. serializer: some GRPCCore.MessageSerializer<Routeguide_Rectangle>,
  591. deserializer: some GRPCCore.MessageDeserializer<Routeguide_Feature>,
  592. options: GRPCCore.CallOptions,
  593. onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse<Routeguide_Feature>) async throws -> Result
  594. ) async throws -> Result where Result: Sendable
  595. /// Call the "RecordRoute" method.
  596. ///
  597. /// > Source IDL Documentation:
  598. /// >
  599. /// > A client-to-server streaming RPC.
  600. /// >
  601. /// > Accepts a stream of Points on a route being traversed, returning a
  602. /// > RouteSummary when traversal is completed.
  603. ///
  604. /// - Parameters:
  605. /// - request: A streaming request producing `Routeguide_Point` messages.
  606. /// - serializer: A serializer for `Routeguide_Point` messages.
  607. /// - deserializer: A deserializer for `Routeguide_RouteSummary` messages.
  608. /// - options: Options to apply to this RPC.
  609. /// - handleResponse: A closure which handles the response, the result of which is
  610. /// returned to the caller. Returning from the closure will cancel the RPC if it
  611. /// hasn't already finished.
  612. /// - Returns: The result of `handleResponse`.
  613. func recordRoute<Result>(
  614. request: GRPCCore.StreamingClientRequest<Routeguide_Point>,
  615. serializer: some GRPCCore.MessageSerializer<Routeguide_Point>,
  616. deserializer: some GRPCCore.MessageDeserializer<Routeguide_RouteSummary>,
  617. options: GRPCCore.CallOptions,
  618. onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<Routeguide_RouteSummary>) async throws -> Result
  619. ) async throws -> Result where Result: Sendable
  620. /// Call the "RouteChat" method.
  621. ///
  622. /// > Source IDL Documentation:
  623. /// >
  624. /// > A Bidirectional streaming RPC.
  625. /// >
  626. /// > Accepts a stream of RouteNotes sent while a route is being traversed,
  627. /// > while receiving other RouteNotes (e.g. from other users).
  628. ///
  629. /// - Parameters:
  630. /// - request: A streaming request producing `Routeguide_RouteNote` messages.
  631. /// - serializer: A serializer for `Routeguide_RouteNote` messages.
  632. /// - deserializer: A deserializer for `Routeguide_RouteNote` messages.
  633. /// - options: Options to apply to this RPC.
  634. /// - handleResponse: A closure which handles the response, the result of which is
  635. /// returned to the caller. Returning from the closure will cancel the RPC if it
  636. /// hasn't already finished.
  637. /// - Returns: The result of `handleResponse`.
  638. func routeChat<Result>(
  639. request: GRPCCore.StreamingClientRequest<Routeguide_RouteNote>,
  640. serializer: some GRPCCore.MessageSerializer<Routeguide_RouteNote>,
  641. deserializer: some GRPCCore.MessageDeserializer<Routeguide_RouteNote>,
  642. options: GRPCCore.CallOptions,
  643. onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse<Routeguide_RouteNote>) async throws -> Result
  644. ) async throws -> Result where Result: Sendable
  645. }
  646. /// Generated client for the "routeguide.RouteGuide" service.
  647. ///
  648. /// The ``Client`` provides an implementation of ``ClientProtocol`` which wraps
  649. /// a `GRPCCore.GRPCCClient`. The underlying `GRPCClient` provides the long-lived
  650. /// means of communication with the remote peer.
  651. ///
  652. /// > Source IDL Documentation:
  653. /// >
  654. /// > Interface exported by the server.
  655. internal struct Client<Transport>: ClientProtocol where Transport: GRPCCore.ClientTransport {
  656. private let client: GRPCCore.GRPCClient<Transport>
  657. /// Creates a new client wrapping the provided `GRPCCore.GRPCClient`.
  658. ///
  659. /// - Parameters:
  660. /// - client: A `GRPCCore.GRPCClient` providing a communication channel to the service.
  661. internal init(wrapping client: GRPCCore.GRPCClient<Transport>) {
  662. self.client = client
  663. }
  664. /// Call the "GetFeature" method.
  665. ///
  666. /// > Source IDL Documentation:
  667. /// >
  668. /// > A simple RPC.
  669. /// >
  670. /// > Obtains the feature at a given position.
  671. /// >
  672. /// > A feature with an empty name is returned if there's no feature at the given
  673. /// > position.
  674. ///
  675. /// - Parameters:
  676. /// - request: A request containing a single `Routeguide_Point` message.
  677. /// - serializer: A serializer for `Routeguide_Point` messages.
  678. /// - deserializer: A deserializer for `Routeguide_Feature` messages.
  679. /// - options: Options to apply to this RPC.
  680. /// - handleResponse: A closure which handles the response, the result of which is
  681. /// returned to the caller. Returning from the closure will cancel the RPC if it
  682. /// hasn't already finished.
  683. /// - Returns: The result of `handleResponse`.
  684. internal func getFeature<Result>(
  685. request: GRPCCore.ClientRequest<Routeguide_Point>,
  686. serializer: some GRPCCore.MessageSerializer<Routeguide_Point>,
  687. deserializer: some GRPCCore.MessageDeserializer<Routeguide_Feature>,
  688. options: GRPCCore.CallOptions = .defaults,
  689. onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<Routeguide_Feature>) async throws -> Result = { response in
  690. try response.message
  691. }
  692. ) async throws -> Result where Result: Sendable {
  693. try await self.client.unary(
  694. request: request,
  695. descriptor: Routeguide_RouteGuide.Method.GetFeature.descriptor,
  696. serializer: serializer,
  697. deserializer: deserializer,
  698. options: options,
  699. onResponse: handleResponse
  700. )
  701. }
  702. /// Call the "ListFeatures" method.
  703. ///
  704. /// > Source IDL Documentation:
  705. /// >
  706. /// > A server-to-client streaming RPC.
  707. /// >
  708. /// > Obtains the Features available within the given Rectangle. Results are
  709. /// > streamed rather than returned at once (e.g. in a response message with a
  710. /// > repeated field), as the rectangle may cover a large area and contain a
  711. /// > huge number of features.
  712. ///
  713. /// - Parameters:
  714. /// - request: A request containing a single `Routeguide_Rectangle` message.
  715. /// - serializer: A serializer for `Routeguide_Rectangle` messages.
  716. /// - deserializer: A deserializer for `Routeguide_Feature` messages.
  717. /// - options: Options to apply to this RPC.
  718. /// - handleResponse: A closure which handles the response, the result of which is
  719. /// returned to the caller. Returning from the closure will cancel the RPC if it
  720. /// hasn't already finished.
  721. /// - Returns: The result of `handleResponse`.
  722. internal func listFeatures<Result>(
  723. request: GRPCCore.ClientRequest<Routeguide_Rectangle>,
  724. serializer: some GRPCCore.MessageSerializer<Routeguide_Rectangle>,
  725. deserializer: some GRPCCore.MessageDeserializer<Routeguide_Feature>,
  726. options: GRPCCore.CallOptions = .defaults,
  727. onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse<Routeguide_Feature>) async throws -> Result
  728. ) async throws -> Result where Result: Sendable {
  729. try await self.client.serverStreaming(
  730. request: request,
  731. descriptor: Routeguide_RouteGuide.Method.ListFeatures.descriptor,
  732. serializer: serializer,
  733. deserializer: deserializer,
  734. options: options,
  735. onResponse: handleResponse
  736. )
  737. }
  738. /// Call the "RecordRoute" method.
  739. ///
  740. /// > Source IDL Documentation:
  741. /// >
  742. /// > A client-to-server streaming RPC.
  743. /// >
  744. /// > Accepts a stream of Points on a route being traversed, returning a
  745. /// > RouteSummary when traversal is completed.
  746. ///
  747. /// - Parameters:
  748. /// - request: A streaming request producing `Routeguide_Point` messages.
  749. /// - serializer: A serializer for `Routeguide_Point` messages.
  750. /// - deserializer: A deserializer for `Routeguide_RouteSummary` messages.
  751. /// - options: Options to apply to this RPC.
  752. /// - handleResponse: A closure which handles the response, the result of which is
  753. /// returned to the caller. Returning from the closure will cancel the RPC if it
  754. /// hasn't already finished.
  755. /// - Returns: The result of `handleResponse`.
  756. internal func recordRoute<Result>(
  757. request: GRPCCore.StreamingClientRequest<Routeguide_Point>,
  758. serializer: some GRPCCore.MessageSerializer<Routeguide_Point>,
  759. deserializer: some GRPCCore.MessageDeserializer<Routeguide_RouteSummary>,
  760. options: GRPCCore.CallOptions = .defaults,
  761. onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<Routeguide_RouteSummary>) async throws -> Result = { response in
  762. try response.message
  763. }
  764. ) async throws -> Result where Result: Sendable {
  765. try await self.client.clientStreaming(
  766. request: request,
  767. descriptor: Routeguide_RouteGuide.Method.RecordRoute.descriptor,
  768. serializer: serializer,
  769. deserializer: deserializer,
  770. options: options,
  771. onResponse: handleResponse
  772. )
  773. }
  774. /// Call the "RouteChat" method.
  775. ///
  776. /// > Source IDL Documentation:
  777. /// >
  778. /// > A Bidirectional streaming RPC.
  779. /// >
  780. /// > Accepts a stream of RouteNotes sent while a route is being traversed,
  781. /// > while receiving other RouteNotes (e.g. from other users).
  782. ///
  783. /// - Parameters:
  784. /// - request: A streaming request producing `Routeguide_RouteNote` messages.
  785. /// - serializer: A serializer for `Routeguide_RouteNote` messages.
  786. /// - deserializer: A deserializer for `Routeguide_RouteNote` messages.
  787. /// - options: Options to apply to this RPC.
  788. /// - handleResponse: A closure which handles the response, the result of which is
  789. /// returned to the caller. Returning from the closure will cancel the RPC if it
  790. /// hasn't already finished.
  791. /// - Returns: The result of `handleResponse`.
  792. internal func routeChat<Result>(
  793. request: GRPCCore.StreamingClientRequest<Routeguide_RouteNote>,
  794. serializer: some GRPCCore.MessageSerializer<Routeguide_RouteNote>,
  795. deserializer: some GRPCCore.MessageDeserializer<Routeguide_RouteNote>,
  796. options: GRPCCore.CallOptions = .defaults,
  797. onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse<Routeguide_RouteNote>) async throws -> Result
  798. ) async throws -> Result where Result: Sendable {
  799. try await self.client.bidirectionalStreaming(
  800. request: request,
  801. descriptor: Routeguide_RouteGuide.Method.RouteChat.descriptor,
  802. serializer: serializer,
  803. deserializer: deserializer,
  804. options: options,
  805. onResponse: handleResponse
  806. )
  807. }
  808. }
  809. }
  810. // Helpers providing default arguments to 'ClientProtocol' methods.
  811. extension Routeguide_RouteGuide.ClientProtocol {
  812. /// Call the "GetFeature" method.
  813. ///
  814. /// > Source IDL Documentation:
  815. /// >
  816. /// > A simple RPC.
  817. /// >
  818. /// > Obtains the feature at a given position.
  819. /// >
  820. /// > A feature with an empty name is returned if there's no feature at the given
  821. /// > position.
  822. ///
  823. /// - Parameters:
  824. /// - request: A request containing a single `Routeguide_Point` message.
  825. /// - options: Options to apply to this RPC.
  826. /// - handleResponse: A closure which handles the response, the result of which is
  827. /// returned to the caller. Returning from the closure will cancel the RPC if it
  828. /// hasn't already finished.
  829. /// - Returns: The result of `handleResponse`.
  830. internal func getFeature<Result>(
  831. request: GRPCCore.ClientRequest<Routeguide_Point>,
  832. options: GRPCCore.CallOptions = .defaults,
  833. onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<Routeguide_Feature>) async throws -> Result = { response in
  834. try response.message
  835. }
  836. ) async throws -> Result where Result: Sendable {
  837. try await self.getFeature(
  838. request: request,
  839. serializer: GRPCProtobuf.ProtobufSerializer<Routeguide_Point>(),
  840. deserializer: GRPCProtobuf.ProtobufDeserializer<Routeguide_Feature>(),
  841. options: options,
  842. onResponse: handleResponse
  843. )
  844. }
  845. /// Call the "ListFeatures" method.
  846. ///
  847. /// > Source IDL Documentation:
  848. /// >
  849. /// > A server-to-client streaming RPC.
  850. /// >
  851. /// > Obtains the Features available within the given Rectangle. Results are
  852. /// > streamed rather than returned at once (e.g. in a response message with a
  853. /// > repeated field), as the rectangle may cover a large area and contain a
  854. /// > huge number of features.
  855. ///
  856. /// - Parameters:
  857. /// - request: A request containing a single `Routeguide_Rectangle` message.
  858. /// - options: Options to apply to this RPC.
  859. /// - handleResponse: A closure which handles the response, the result of which is
  860. /// returned to the caller. Returning from the closure will cancel the RPC if it
  861. /// hasn't already finished.
  862. /// - Returns: The result of `handleResponse`.
  863. internal func listFeatures<Result>(
  864. request: GRPCCore.ClientRequest<Routeguide_Rectangle>,
  865. options: GRPCCore.CallOptions = .defaults,
  866. onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse<Routeguide_Feature>) async throws -> Result
  867. ) async throws -> Result where Result: Sendable {
  868. try await self.listFeatures(
  869. request: request,
  870. serializer: GRPCProtobuf.ProtobufSerializer<Routeguide_Rectangle>(),
  871. deserializer: GRPCProtobuf.ProtobufDeserializer<Routeguide_Feature>(),
  872. options: options,
  873. onResponse: handleResponse
  874. )
  875. }
  876. /// Call the "RecordRoute" method.
  877. ///
  878. /// > Source IDL Documentation:
  879. /// >
  880. /// > A client-to-server streaming RPC.
  881. /// >
  882. /// > Accepts a stream of Points on a route being traversed, returning a
  883. /// > RouteSummary when traversal is completed.
  884. ///
  885. /// - Parameters:
  886. /// - request: A streaming request producing `Routeguide_Point` messages.
  887. /// - options: Options to apply to this RPC.
  888. /// - handleResponse: A closure which handles the response, the result of which is
  889. /// returned to the caller. Returning from the closure will cancel the RPC if it
  890. /// hasn't already finished.
  891. /// - Returns: The result of `handleResponse`.
  892. internal func recordRoute<Result>(
  893. request: GRPCCore.StreamingClientRequest<Routeguide_Point>,
  894. options: GRPCCore.CallOptions = .defaults,
  895. onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<Routeguide_RouteSummary>) async throws -> Result = { response in
  896. try response.message
  897. }
  898. ) async throws -> Result where Result: Sendable {
  899. try await self.recordRoute(
  900. request: request,
  901. serializer: GRPCProtobuf.ProtobufSerializer<Routeguide_Point>(),
  902. deserializer: GRPCProtobuf.ProtobufDeserializer<Routeguide_RouteSummary>(),
  903. options: options,
  904. onResponse: handleResponse
  905. )
  906. }
  907. /// Call the "RouteChat" method.
  908. ///
  909. /// > Source IDL Documentation:
  910. /// >
  911. /// > A Bidirectional streaming RPC.
  912. /// >
  913. /// > Accepts a stream of RouteNotes sent while a route is being traversed,
  914. /// > while receiving other RouteNotes (e.g. from other users).
  915. ///
  916. /// - Parameters:
  917. /// - request: A streaming request producing `Routeguide_RouteNote` messages.
  918. /// - options: Options to apply to this RPC.
  919. /// - handleResponse: A closure which handles the response, the result of which is
  920. /// returned to the caller. Returning from the closure will cancel the RPC if it
  921. /// hasn't already finished.
  922. /// - Returns: The result of `handleResponse`.
  923. internal func routeChat<Result>(
  924. request: GRPCCore.StreamingClientRequest<Routeguide_RouteNote>,
  925. options: GRPCCore.CallOptions = .defaults,
  926. onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse<Routeguide_RouteNote>) async throws -> Result
  927. ) async throws -> Result where Result: Sendable {
  928. try await self.routeChat(
  929. request: request,
  930. serializer: GRPCProtobuf.ProtobufSerializer<Routeguide_RouteNote>(),
  931. deserializer: GRPCProtobuf.ProtobufDeserializer<Routeguide_RouteNote>(),
  932. options: options,
  933. onResponse: handleResponse
  934. )
  935. }
  936. }
  937. // Helpers providing sugared APIs for 'ClientProtocol' methods.
  938. extension Routeguide_RouteGuide.ClientProtocol {
  939. /// Call the "GetFeature" method.
  940. ///
  941. /// > Source IDL Documentation:
  942. /// >
  943. /// > A simple RPC.
  944. /// >
  945. /// > Obtains the feature at a given position.
  946. /// >
  947. /// > A feature with an empty name is returned if there's no feature at the given
  948. /// > position.
  949. ///
  950. /// - Parameters:
  951. /// - message: request message to send.
  952. /// - metadata: Additional metadata to send, defaults to empty.
  953. /// - options: Options to apply to this RPC, defaults to `.defaults`.
  954. /// - handleResponse: A closure which handles the response, the result of which is
  955. /// returned to the caller. Returning from the closure will cancel the RPC if it
  956. /// hasn't already finished.
  957. /// - Returns: The result of `handleResponse`.
  958. internal func getFeature<Result>(
  959. _ message: Routeguide_Point,
  960. metadata: GRPCCore.Metadata = [:],
  961. options: GRPCCore.CallOptions = .defaults,
  962. onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<Routeguide_Feature>) async throws -> Result = { response in
  963. try response.message
  964. }
  965. ) async throws -> Result where Result: Sendable {
  966. let request = GRPCCore.ClientRequest<Routeguide_Point>(
  967. message: message,
  968. metadata: metadata
  969. )
  970. return try await self.getFeature(
  971. request: request,
  972. options: options,
  973. onResponse: handleResponse
  974. )
  975. }
  976. /// Call the "ListFeatures" method.
  977. ///
  978. /// > Source IDL Documentation:
  979. /// >
  980. /// > A server-to-client streaming RPC.
  981. /// >
  982. /// > Obtains the Features available within the given Rectangle. Results are
  983. /// > streamed rather than returned at once (e.g. in a response message with a
  984. /// > repeated field), as the rectangle may cover a large area and contain a
  985. /// > huge number of features.
  986. ///
  987. /// - Parameters:
  988. /// - message: request message to send.
  989. /// - metadata: Additional metadata to send, defaults to empty.
  990. /// - options: Options to apply to this RPC, defaults to `.defaults`.
  991. /// - handleResponse: A closure which handles the response, the result of which is
  992. /// returned to the caller. Returning from the closure will cancel the RPC if it
  993. /// hasn't already finished.
  994. /// - Returns: The result of `handleResponse`.
  995. internal func listFeatures<Result>(
  996. _ message: Routeguide_Rectangle,
  997. metadata: GRPCCore.Metadata = [:],
  998. options: GRPCCore.CallOptions = .defaults,
  999. onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse<Routeguide_Feature>) async throws -> Result
  1000. ) async throws -> Result where Result: Sendable {
  1001. let request = GRPCCore.ClientRequest<Routeguide_Rectangle>(
  1002. message: message,
  1003. metadata: metadata
  1004. )
  1005. return try await self.listFeatures(
  1006. request: request,
  1007. options: options,
  1008. onResponse: handleResponse
  1009. )
  1010. }
  1011. /// Call the "RecordRoute" method.
  1012. ///
  1013. /// > Source IDL Documentation:
  1014. /// >
  1015. /// > A client-to-server streaming RPC.
  1016. /// >
  1017. /// > Accepts a stream of Points on a route being traversed, returning a
  1018. /// > RouteSummary when traversal is completed.
  1019. ///
  1020. /// - Parameters:
  1021. /// - metadata: Additional metadata to send, defaults to empty.
  1022. /// - options: Options to apply to this RPC, defaults to `.defaults`.
  1023. /// - producer: A closure producing request messages to send to the server. The request
  1024. /// stream is closed when the closure returns.
  1025. /// - handleResponse: A closure which handles the response, the result of which is
  1026. /// returned to the caller. Returning from the closure will cancel the RPC if it
  1027. /// hasn't already finished.
  1028. /// - Returns: The result of `handleResponse`.
  1029. internal func recordRoute<Result>(
  1030. metadata: GRPCCore.Metadata = [:],
  1031. options: GRPCCore.CallOptions = .defaults,
  1032. requestProducer producer: @Sendable @escaping (GRPCCore.RPCWriter<Routeguide_Point>) async throws -> Void,
  1033. onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<Routeguide_RouteSummary>) async throws -> Result = { response in
  1034. try response.message
  1035. }
  1036. ) async throws -> Result where Result: Sendable {
  1037. let request = GRPCCore.StreamingClientRequest<Routeguide_Point>(
  1038. metadata: metadata,
  1039. producer: producer
  1040. )
  1041. return try await self.recordRoute(
  1042. request: request,
  1043. options: options,
  1044. onResponse: handleResponse
  1045. )
  1046. }
  1047. /// Call the "RouteChat" method.
  1048. ///
  1049. /// > Source IDL Documentation:
  1050. /// >
  1051. /// > A Bidirectional streaming RPC.
  1052. /// >
  1053. /// > Accepts a stream of RouteNotes sent while a route is being traversed,
  1054. /// > while receiving other RouteNotes (e.g. from other users).
  1055. ///
  1056. /// - Parameters:
  1057. /// - metadata: Additional metadata to send, defaults to empty.
  1058. /// - options: Options to apply to this RPC, defaults to `.defaults`.
  1059. /// - producer: A closure producing request messages to send to the server. The request
  1060. /// stream is closed when the closure returns.
  1061. /// - handleResponse: A closure which handles the response, the result of which is
  1062. /// returned to the caller. Returning from the closure will cancel the RPC if it
  1063. /// hasn't already finished.
  1064. /// - Returns: The result of `handleResponse`.
  1065. internal func routeChat<Result>(
  1066. metadata: GRPCCore.Metadata = [:],
  1067. options: GRPCCore.CallOptions = .defaults,
  1068. requestProducer producer: @Sendable @escaping (GRPCCore.RPCWriter<Routeguide_RouteNote>) async throws -> Void,
  1069. onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse<Routeguide_RouteNote>) async throws -> Result
  1070. ) async throws -> Result where Result: Sendable {
  1071. let request = GRPCCore.StreamingClientRequest<Routeguide_RouteNote>(
  1072. metadata: metadata,
  1073. producer: producer
  1074. )
  1075. return try await self.routeChat(
  1076. request: request,
  1077. options: options,
  1078. onResponse: handleResponse
  1079. )
  1080. }
  1081. }