pub struct AsyncPreparedStatement<'conn> { /* private fields */ }Expand description
A handle to a server-side prepared statement (async).
Construct via AsyncConnection::prepare or
AsyncConnection::prepare_typed. Holding this type keeps the
statement allocated on the server; it is released automatically when
the handle is dropped (best-effort — see
hyperdb_api_core::client::AsyncPreparedStatement for the Drop semantics).
The owned variant AsyncPreparedStatementOwned also provides an
explicit close method for
callers that want deterministic cleanup.
Implementations§
Source§impl<'conn> AsyncPreparedStatement<'conn>
impl<'conn> AsyncPreparedStatement<'conn>
Sourcepub fn param_count(&self) -> usize
pub fn param_count(&self) -> usize
Number of parameters the statement expects.
Sourcepub fn param_types(&self) -> &[Oid]
pub fn param_types(&self) -> &[Oid]
Parameter type OIDs.
Sourcepub fn schema(&self) -> &ResultSchema
pub fn schema(&self) -> &ResultSchema
Result-column schema, always available (captured at prepare time).
Sourcepub async fn query(
&self,
params: &[&dyn ToSqlParam],
) -> Result<AsyncRowset<'conn>>
pub async fn query( &self, params: &[&dyn ToSqlParam], ) -> Result<AsyncRowset<'conn>>
Executes the statement and returns a streaming AsyncRowset.
§Errors
- Returns
Error::Otheron gRPC transport. - Returns
Error::Clientif the server rejectsBindorExecute. - Returns
Error::Ioon transport-level I/O failures.
Sourcepub async fn execute(&self, params: &[&dyn ToSqlParam]) -> Result<u64>
pub async fn execute(&self, params: &[&dyn ToSqlParam]) -> Result<u64>
Executes the statement as a command and returns the affected-row count (async).
§Errors
- Returns
Error::Otheron gRPC transport. - Returns
Error::Clientif the server rejectsBindorExecute. - Returns
Error::Ioon transport-level I/O failures.
Sourcepub async fn fetch_one(&self, params: &[&dyn ToSqlParam]) -> Result<Row>
pub async fn fetch_one(&self, params: &[&dyn ToSqlParam]) -> Result<Row>
Fetches exactly one row; errors if the result is empty.
§Errors
- Returns the error from
query. - Returns
Error::Otherwith message"Query returned no rows"if the result is empty.
Sourcepub async fn fetch_optional(
&self,
params: &[&dyn ToSqlParam],
) -> Result<Option<Row>>
pub async fn fetch_optional( &self, params: &[&dyn ToSqlParam], ) -> Result<Option<Row>>
Sourcepub async fn fetch_scalar<T: RowValue>(
&self,
params: &[&dyn ToSqlParam],
) -> Result<T>
pub async fn fetch_scalar<T: RowValue>( &self, params: &[&dyn ToSqlParam], ) -> Result<T>
Fetches a single non-NULL scalar; errors on empty / NULL.
§Errors
- Returns the error from
query. - Returns
Error::Otherwith message"Query returned no rows"if the result is empty. - Returns
Error::Otherwith message"Scalar query returned NULL"if the first cell is SQLNULL.
Sourcepub async fn fetch_optional_scalar<T: RowValue>(
&self,
params: &[&dyn ToSqlParam],
) -> Result<Option<T>>
pub async fn fetch_optional_scalar<T: RowValue>( &self, params: &[&dyn ToSqlParam], ) -> Result<Option<T>>
Trait Implementations§
Auto Trait Implementations§
impl<'conn> Freeze for AsyncPreparedStatement<'conn>
impl<'conn> !RefUnwindSafe for AsyncPreparedStatement<'conn>
impl<'conn> Send for AsyncPreparedStatement<'conn>
impl<'conn> Sync for AsyncPreparedStatement<'conn>
impl<'conn> Unpin for AsyncPreparedStatement<'conn>
impl<'conn> UnsafeUnpin for AsyncPreparedStatement<'conn>
impl<'conn> !UnwindSafe for AsyncPreparedStatement<'conn>
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request