recvTimeout method
Attempts to wait for a value on this receiver with a time limit, returning Err
of:
DisconnectedError if the Sender called close and the buffer is empty.
OtherError if the item in the buffer is an error, indicated by the sender calling addError
.
TimeoutError if the time limit is reached before the Sender sent any more data.
Implementation
@override
Future<Result<T, RecvTimeoutError>> recvTimeout(Duration timeLimit) async {
try {
return await _next()
.timeout(timeLimit)
.mapErr((error) => error as RecvTimeoutError);
} on TimeoutException catch (timeoutException) {
return Err(TimeoutError(timeoutException));
} catch (error) {
return Err(OtherError(error));
}
}