#[non_exhaustive]pub struct CursorStream<'a> { /* private fields */ }Expand description
A streaming cursor that yields rows one at a time from a portal.
Unlike Cursor which returns batches of rows, CursorStream provides
a row-by-row iterator interface. When the current batch is exhausted,
it automatically fetches the next batch from the server.
CursorStream borrows the connection mutably. You cannot use the
connection while iterating. 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.
Implementations§
Source§impl<'a> CursorStream<'a>
impl<'a> CursorStream<'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) -> &[FieldDescription]
pub fn columns(&self) -> &[FieldDescription]
Get the column metadata for the current result set.
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 fn command_tag(&self) -> Option<&CommandTag>
pub fn command_tag(&self) -> Option<&CommandTag>
Get the command tag after the stream ends.
Sourcepub async fn consume(self) -> Result<CommandTag>
pub async fn consume(self) -> Result<CommandTag>
Consume the remaining rows in the stream, discarding them, and close the cursor portal.