pub struct AsyncPreparedStatementOwned { /* private fields */ }Expand description
Owned-handle variant of AsyncPreparedStatement that holds an
Arc<AsyncConnection> instead of a borrow.
Semantics are identical to AsyncPreparedStatement. The only
difference is that this variant is 'static and can therefore live
in structs that can’t carry lifetimes — N-API classes, tokio::spawn
tasks that outlive the constructor, etc.
Implementations§
Source§impl AsyncPreparedStatementOwned
impl AsyncPreparedStatementOwned
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, captured at prepare time.
Sourcepub async fn fetch_all(&self, params: &[&dyn ToSqlParam]) -> Result<Vec<Row>>
pub async fn fetch_all(&self, params: &[&dyn ToSqlParam]) -> Result<Vec<Row>>
Executes the statement and returns a materialized Vec<Row>.
Unlike AsyncPreparedStatement::query, the owned variant
returns an owned Vec<Row> rather than a streaming
AsyncRowset: AsyncRowset is itself lifetime-bound to
the connection’s mutex guard, which defeats the purpose of the
owned wrapper. N-API callers that want streaming should fall
back to the non-owned AsyncPreparedStatement via
AsyncConnection::prepare or use the non-streaming query
methods below.
§Errors
- Returns
Error::Otheron gRPC transport. - Returns
Error::Clientif the server rejectsBindorExecute, or raises a runtime error while streaming. - 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; returns the affected-row count.
§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 on empty.
§Errors
- Returns the error from
fetch_all. - 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 the first column of the first row as T.
§Errors
- Returns the error from
fetch_one. - 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>>
Fetches the first column of the first row as Option<T>.
§Errors
Returns the error from fetch_optional;
SQL NULL yields Ok(None).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AsyncPreparedStatementOwned
impl !RefUnwindSafe for AsyncPreparedStatementOwned
impl Send for AsyncPreparedStatementOwned
impl Sync for AsyncPreparedStatementOwned
impl Unpin for AsyncPreparedStatementOwned
impl UnsafeUnpin for AsyncPreparedStatementOwned
impl !UnwindSafe for AsyncPreparedStatementOwned
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