Functions
Cancel()
Cancels the current download.
Callers should continue reading until Read()
is satisfied with a Status
.
This function is implemented using gMock's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Returns | |
---|---|
Type | Description |
void |
Read()
Asks for more data.
An outcome with a Status
indicates that no more data is available. Calling Read()
after it returns a Status
results in undefined behavior.
Applications should not have more than one Read()
pending at a time. Calling Read()
while a previous Read()
is pending results in undefined behavior.
Applications should not destruct an AsyncReaderConnection
until a call to Read()
returns a Status
response.
Retrieving more data can result in three outcomes:
- Additional data (a
ReadPayload
) is available: in this case the future is satisfied with aReadResponse
containing aReadPayload
. - The download is interrupted with an error: in this case the future is satisfied with a
ReadResponse
containing aStatus
that describes the error. - The download has completed successfully: in this case the future is satisfied with a
ReadResponse
containing an OKStatus
.
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.
This function is implemented using gMock's MOCK_METHOD()
.
Consult the gMock documentation to use this mock in your tests.
Returns | |
---|---|
Type | Description |
future< ReadResponse > |
Type Aliases
ReadResponse
absl::variant< ReadPayload, Status >
The value returned by Read()
. See the function for more details.