File tree Expand file tree Collapse file tree 2 files changed +11
-23
lines changed
Sources/GRPCCore/Call/Client
Tests/GRPCCoreTests/Call/Client Expand file tree Collapse file tree 2 files changed +11
-23
lines changed Original file line number Diff line number Diff line change @@ -363,7 +363,7 @@ extension StreamingClientResponse {
363
363
364
364
/// Returns the messages received from the server.
365
365
///
366
- /// For rejected RPCs the `RPCAsyncSequence` throws a `RPCError``.
366
+ /// For rejected RPCs (in other words, where ``accepted`` is `failure`), the `RPCAsyncSequence` throws a `RPCError``.
367
367
public var messages : RPCAsyncSequence < Message , any Error > {
368
368
switch self . accepted {
369
369
case let . success( contents) :
@@ -385,10 +385,16 @@ extension StreamingClientResponse {
385
385
386
386
/// Returns the body parts (i.e. `messages` and `trailingMetadata`) returned from the server.
387
387
///
388
- /// For rejected RPCs (in other words, where ``accepted`` is `failure`), this method throws an `RPCError`.
388
+ /// For rejected RPCs (in other words, where ``accepted`` is `failure`), the `RPCAsyncSequence` throws a `RPCError` `.
389
389
public var bodyParts : RPCAsyncSequence < Contents . BodyPart , any Error > {
390
- get throws {
391
- try self . accepted. get ( ) . bodyParts
390
+ switch self . accepted {
391
+ case let . success( contents) :
392
+ return contents. bodyParts
393
+
394
+ case let . failure( error) :
395
+ return RPCAsyncSequence . throwing ( error)
392
396
}
393
397
}
394
398
}
399
+
400
+ extension StreamingClientResponse . Contents . BodyPart : Equatable where Message: Equatable { }
Original file line number Diff line number Diff line change @@ -107,7 +107,7 @@ final class ClientResponseTests: XCTestCase {
107
107
XCTAssertEqual ( $0, error)
108
108
}
109
109
await XCTAssertThrowsRPCErrorAsync {
110
- try response. bodyParts
110
+ try await response. bodyParts. collect ( )
111
111
} errorHandler: {
112
112
XCTAssertEqual ( $0, error)
113
113
}
@@ -210,21 +210,3 @@ final class ClientResponseTests: XCTestCase {
210
210
}
211
211
}
212
212
}
213
-
214
- extension StreamingClientResponse . Contents . BodyPart : Equatable where Message: Equatable {
215
- static func == (
216
- lhs: StreamingClientResponse . Contents . BodyPart ,
217
- rhs: StreamingClientResponse . Contents . BodyPart
218
- ) -> Bool {
219
- switch ( lhs, rhs) {
220
- case ( . message( let lhsMessage) , . message( let rhsMessage) ) :
221
- return lhsMessage == rhsMessage
222
-
223
- case ( . trailingMetadata( let lhsMetadata) , . trailingMetadata( let rhsMetadata) ) :
224
- return lhsMetadata == rhsMetadata
225
-
226
- default :
227
- return false
228
- }
229
- }
230
- }
You can’t perform that action at this time.
0 commit comments