Retrieving more data can result in three outcomes:
Additional data (a ReadPayload) is available: in this case the future is satisfied with a ReadResponse containing a ReadPayload.
The download is interrupted with an error: in this case the future is satisfied with a ReadResponse containing a Status that describes the error.
The download has completed successfully: in this case the future is satisfied with a ReadResponse containing an OK Status.
A StatusOr<> cannot represent the last bullet point, so we need an absl::variant<> in this case. We could have used StatusOr<absl::optional<ReadPayload>> but that sounds unnecessarily complicated.
Returns
Type
Description
future< ReadResponse >
GetRequestMetadata()
Return the request metadata.
Returns
Type
Description
RpcMetadata
Type Aliases
ReadResponse
Alias Of: absl::variant< ReadPayload, Status >
The value returned by Read(). See the function for more details.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-05-07 UTC."],[[["This document outlines the `AsyncReaderConnection` class, which is typically used indirectly via the `AsyncReader` class for managing asynchronous data reading."],["The `Cancel()` function can be used to halt the ongoing download operation, but the application must continue reading until a `Status` is returned."],["The `Read()` function retrieves more data, and it should be noted that only one `Read()` should be pending at any time to avoid undefined behavior, with a `Status` signaling the end of data."],["`Read()` returns a `future\u003cReadResponse\u003e` which can contain either `ReadPayload` if more data is available, or a `Status` indicating an error or the successful completion of a download."],["The `ReadResponse` type alias is a variant of `ReadPayload` or `Status`, representing the possible outcomes of a `Read()` call, and `GetRequestMetadata` is a function to return request metadata."]]],[]]