@@ -436,7 +436,27 @@ async/await language constructs), they provide throwing APIs to access the final
436
436
metadata for the RPC. We could consider doing the same and have not ruled it
437
437
out.
438
438
439
+ ### Opaque return type for response streams
440
+
441
+ It would be nice if we didn't have to return the `GRPCAsyncStream` wrapper type
442
+ for server- streaming RPCs. Ideally we would be able to declare an opaque return
443
+ type with a constraint on its associated type. This would make the return type of
444
+ server- streaming calls more symmetric with the inputs to client- streaming calls.
445
+ For example, the bidirectional API could be defined as follows:
446
+
447
+ ```swift
448
+ func update< RequestStream> (
449
+ requests : RequestStream,
450
+ callOptions : CallOptions? = nil
451
+ ) -> some AsyncSequence where Element == Echo_EchoResponse
452
+ where RequestStream: AsyncSequence, RequestStream.Element == Echo_EchoRequest
453
+ ```
454
+
455
+ Unfortunately this isn't currently supported by `AsyncSequence`, but it _has_
456
+ been called out as a [possible future enhancement][opaque- asyncsequence].
457
+
439
458
[SE- 0296 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0296-async-await.md
440
459
[SE- 0298 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0298-asyncsequence.md
441
460
[SE- 0310 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0310-effectful-readonly-properties.md
442
461
[SE- 0314 ]: https: // github.com/apple/swift-evolution/blob/main/proposals/0314-async-stream.md
462
+ [opaque- asyncsequence]: https: // github.com/apple/swift-evolution/blob/0c2f85b3/proposals/0298-asyncsequence.md#opaque-types
0 commit comments