pub struct NamedPortal<'tx> { /* private fields */ }Expand description
Handle to a named portal for async iterative row fetching.
Created by [Transaction::exec_portal_named()]. Use exec() to retrieve rows
in batches. The lifetime parameter ties the portal to the transaction that created it,
preventing the transaction from being committed/rolled back while the portal is alive.
§Example
ⓘ
conn.transaction(|conn, tx| async move {
let mut portal = tx.exec_portal_named(conn, &stmt, ()).await?;
while !portal.is_complete() {
let rows: Vec<(i32,)> = portal.exec_collect(conn, 100).await?;
process(rows);
}
portal.close(conn).await?;
tx.commit(conn).await
}).await?;Implementations§
Source§impl<'tx> NamedPortal<'tx>
impl<'tx> NamedPortal<'tx>
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Check if portal execution is complete (no more rows available).
Sourcepub async fn exec<H: ExtendedHandler>(
&mut self,
conn: &mut Conn,
max_rows: u32,
handler: &mut H,
) -> Result<()>
pub async fn exec<H: ExtendedHandler>( &mut self, conn: &mut Conn, max_rows: u32, handler: &mut H, ) -> Result<()>
Execute the portal with a handler.
Fetches up to max_rows rows. Pass 0 to fetch all remaining rows.
Updates internal completion status.
Sourcepub async fn exec_collect<T: for<'a> FromRow<'a>>(
&mut self,
conn: &mut Conn,
max_rows: u32,
) -> Result<Vec<T>>
pub async fn exec_collect<T: for<'a> FromRow<'a>>( &mut self, conn: &mut Conn, max_rows: u32, ) -> Result<Vec<T>>
Execute the portal and collect typed rows.
Fetches up to max_rows rows. Pass 0 to fetch all remaining rows.
Auto Trait Implementations§
impl<'tx> Freeze for NamedPortal<'tx>
impl<'tx> RefUnwindSafe for NamedPortal<'tx>
impl<'tx> Send for NamedPortal<'tx>
impl<'tx> Sync for NamedPortal<'tx>
impl<'tx> Unpin for NamedPortal<'tx>
impl<'tx> UnwindSafe for NamedPortal<'tx>
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