zero_postgres/tokio/unnamed_portal.rs
1//! Unnamed portal for async iterative row fetching.
2
3use crate::error::Result;
4use crate::handler::BinaryHandler;
5
6use super::Conn;
7
8/// Handle to an unnamed portal for async iterative row fetching.
9///
10/// Created by [`Conn::exec_iter()`]. Use [`fetch()`](Self::fetch) to retrieve rows in batches.
11pub struct UnnamedPortal<'a> {
12 pub(crate) conn: &'a mut Conn,
13}
14
15impl<'a> UnnamedPortal<'a> {
16 /// Fetch up to `max_rows` rows using the provided handler.
17 ///
18 /// Returns `Ok(true)` if more rows available (PortalSuspended received).
19 /// Returns `Ok(false)` if all rows fetched (CommandComplete received).
20 pub async fn fetch<H: BinaryHandler>(
21 &mut self,
22 max_rows: u32,
23 handler: &mut H,
24 ) -> Result<bool> {
25 self.conn.lowlevel_execute("", max_rows, handler).await
26 }
27}