#[non_exhaustive]pub struct RowStream<'a> { /* private fields */ }Expand description
An async stream of rows from a query result.
Rows are fetched from the server one at a time as the consumer calls next().
This provides natural backpressure and O(1) memory per row.
RowStream borrows the connection mutably. You cannot use the connection
while iterating the stream. When the stream is dropped (or fully consumed),
the connection is available again.
If the stream is dropped before being fully consumed, the connection is
left in an inconsistent state. The Connection::needs_recovery flag is
set, and you must call Connection::recover before using the connection
again. To avoid this, either consume the stream fully or call
RowStream::consume before dropping.
Implementations§
Source§impl<'a> RowStream<'a>
impl<'a> RowStream<'a>
Sourcepub async fn next(&mut self) -> Result<Option<Row>>
pub async fn next(&mut self) -> Result<Option<Row>>
Fetch the next row from the stream.
Returns Ok(Some(row)) when a row is available, Ok(None) when the
stream is exhausted, and Err(...) on a server or protocol error.
After returning None or Err, subsequent calls return None.
Sourcepub fn columns(&self) -> Option<&[FieldDescription]>
pub fn columns(&self) -> Option<&[FieldDescription]>
Get the column metadata for the current result set.
Sourcepub fn command_tag(&self) -> Option<&CommandTag>
pub fn command_tag(&self) -> Option<&CommandTag>
Get the command tag after the stream ends.
Sourcepub fn is_done(&self) -> bool
pub fn is_done(&self) -> bool
Returns true if the stream has been fully consumed or encountered an error.
Sourcepub async fn consume(self) -> Result<CommandTag>
pub async fn consume(self) -> Result<CommandTag>
Consume the remaining rows in the stream, discarding them.