pub struct RowStream<'a> { /* private fields */ }Expand description
A streaming row-by-row iterator over query results.
Created by [Connection::query_stream()]. Yields rows one at a time
via next(), avoiding full materialization of
large result sets in memory.
The stream holds an exclusive borrow of the connection — no other queries can run until the stream is dropped or fully consumed.
§Example
let mut stream = conn.query_stream("SELECT * FROM users", &[]).await?;
while let Some(row) = stream.next().await? {
let name: String = row.get(0);
}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)) for each row, Ok(None) when the query
is complete, or Err on server/protocol error.
Sourcepub async fn close(self) -> Result<()>
pub async fn close(self) -> Result<()>
Close the stream early, draining any remaining server messages.
Call this instead of dropping when you want to reuse the connection for subsequent queries after only partially consuming the stream.
Sourcepub fn description(&self) -> &RowDescription
pub fn description(&self) -> &RowDescription
The row description for this stream’s columns.
Auto Trait Implementations§
impl<'a> Freeze for RowStream<'a>
impl<'a> !RefUnwindSafe for RowStream<'a>
impl<'a> Send for RowStream<'a>
impl<'a> Sync for RowStream<'a>
impl<'a> Unpin for RowStream<'a>
impl<'a> UnsafeUnpin for RowStream<'a>
impl<'a> !UnwindSafe for RowStream<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more