zero_postgres/sync/unnamed_portal.rs
1//! Unnamed portal for iterative row fetching.
2
3use crate::error::Result;
4use crate::handler::BinaryHandler;
5
6use super::Conn;
7
8/// Handle to an unnamed portal for 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 fn fetch<H: BinaryHandler>(&mut self, max_rows: u32, handler: &mut H) -> Result<bool> {
21 self.conn.lowlevel_execute("", max_rows, handler)
22 }
23}