use crate::conversion::FromRow;
use crate::error::Result;
use crate::handler::{ExtendedHandler, ForEachHandler};
use super::Conn;
pub struct UnnamedPortal<'a> {
pub(crate) conn: &'a mut Conn,
}
impl<'a> UnnamedPortal<'a> {
pub async fn exec<H: ExtendedHandler>(
&mut self,
max_rows: u32,
handler: &mut H,
) -> Result<bool> {
self.conn.lowlevel_execute("", max_rows, handler).await
}
pub async fn exec_foreach<T: for<'b> FromRow<'b>, F: FnMut(T) -> Result<()>>(
&mut self,
max_rows: u32,
f: F,
) -> Result<bool> {
let mut handler = ForEachHandler::<T, F>::new(f);
self.exec(max_rows, &mut handler).await
}
}