pub struct AsyncRowset<'conn> { /* private fields */ }Expand description
A streaming result set returned from an async query.
See Rowset for the sync equivalent and the full
memory-behavior contract — both use constant-memory chunked iteration.
Implementations§
Source§impl<'conn> AsyncRowset<'conn>
impl<'conn> AsyncRowset<'conn>
Sourcepub fn schema(&self) -> Option<ResultSchema>
pub fn schema(&self) -> Option<ResultSchema>
Returns the schema (column metadata) for the result set.
For TCP this returns None until the first chunk has been
fetched (the RowDescription is the first message of the
stream). For Arrow it is available immediately.
Sourcepub async fn next_chunk(&mut self) -> Result<Option<Vec<Row>>>
pub async fn next_chunk(&mut self) -> Result<Option<Vec<Row>>>
Returns the next chunk of rows, or None when the stream is
exhausted.
§Errors
- Returns
crate::Error::Clientif the server sends anErrorResponsewhile streaming the result set. - Returns
crate::Error::Ioon transport-level I/O failures. - Returns
crate::Error::Otherif an Arrow IPC chunk cannot be decoded.
Sourcepub async fn collect_rows(self) -> Result<Vec<Row>>
pub async fn collect_rows(self) -> Result<Vec<Row>>
Collects every remaining row into a Vec. Consumes the rowset.
§Errors
Returns the first error produced by next_chunk
while draining the stream.
Sourcepub async fn collect_column<T: RowValue>(self) -> Result<Vec<Option<T>>>
pub async fn collect_column<T: RowValue>(self) -> Result<Vec<Option<T>>>
Collects the first column of every row, preserving NULL as None.
§Errors
Returns the first error produced by next_chunk.
SQL NULL cells yield Option::None entries, not errors.
Sourcepub async fn collect_column_non_null<T: RowValue>(self) -> Result<Vec<T>>
pub async fn collect_column_non_null<T: RowValue>(self) -> Result<Vec<T>>
Collects the first column of every row, dropping NULLs.
§Errors
Returns the first error produced by
collect_column.
Sourcepub async fn first_row(self) -> Result<Option<Row>>
pub async fn first_row(self) -> Result<Option<Row>>
Returns the first row of the result set, or None if the
result is empty. Consumes the rowset.
§Errors
Returns the error from next_chunk. An empty
result yields Ok(None).
Sourcepub async fn require_first_row(self) -> Result<Row>
pub async fn require_first_row(self) -> Result<Row>
Returns the first row, or an error if the result set is empty.
§Errors
- Returns the error from
first_row. - Returns
crate::Error::Otherwith message"Query returned no rows"if the result set is empty.
Sourcepub async fn scalar<T: RowValue>(self) -> Result<Option<T>>
pub async fn scalar<T: RowValue>(self) -> Result<Option<T>>
Returns the first column of the first row as Option<T>, or an
error if the result set is empty.
§Errors
Returns the error from
require_first_row. SQL NULL in the
single cell yields Ok(None).
Sourcepub async fn require_scalar<T: RowValue>(self) -> Result<T>
pub async fn require_scalar<T: RowValue>(self) -> Result<T>
Returns the first column of the first row as T, or an error
if the result set is empty or the value is NULL.
§Errors
- Returns the error from
scalar. - Returns
crate::Error::Otherwith message"Scalar query returned NULL"if the single cell is SQLNULL.
Trait Implementations§
Auto Trait Implementations§
impl<'conn> Freeze for AsyncRowset<'conn>
impl<'conn> !RefUnwindSafe for AsyncRowset<'conn>
impl<'conn> Send for AsyncRowset<'conn>
impl<'conn> !Sync for AsyncRowset<'conn>
impl<'conn> Unpin for AsyncRowset<'conn>
impl<'conn> UnsafeUnpin for AsyncRowset<'conn>
impl<'conn> !UnwindSafe for AsyncRowset<'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