pub struct RowStream<'a, S: ConnectionState = Ready> { /* private fields */ }Expand description
An incrementally streamed result set: rows are read from the network as they are pulled, not buffered up front.
See the module docs for how this differs from
QueryStream. Obtain one from
Client::query_stream.
Pulling is async (each row may require reading another packet), so this type
is consumed via try_next / collect_all
rather than the synchronous Iterator that QueryStream offers.
Implementations§
Source§impl<'a, S: ConnectionState> RowStream<'a, S>
impl<'a, S: ConnectionState> RowStream<'a, S>
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Whether the stream has been fully consumed.
Sourcepub async fn try_next(&mut self) -> Result<Option<Row>>
pub async fn try_next(&mut self) -> Result<Option<Row>>
Pull the next row, reading more packets from the connection as needed.
Returns Ok(None) once the response is fully drained — at which point
the connection is clean for the next request. A server error token in
the stream is surfaced here as Error::Server.
Sourcepub async fn collect_all(self) -> Result<Vec<Row>>
pub async fn collect_all(self) -> Result<Vec<Row>>
Drain the remaining rows into a vector.
For large result sets prefer try_next — this loads
every remaining row into memory at once.
Sourcepub async fn cancel(self) -> Result<()>
pub async fn cancel(self) -> Result<()>
Stop the stream early and leave the connection reusable.
Sends an Attention to the server and drains to its acknowledgement so the connection is clean for the next request — the correct way to abandon a large result set you no longer need.
Calling this is optional: simply dropping a partially-read stream is
safe but leaves the connection marked in-flight, so a pooled connection
is discarded on return and a directly reused client recovers it (with an
Attention/drain) on its next request. cancel avoids that discard and
reports any error from the cancellation.