Struct scylla::transport::query_result::QueryRowsResult
source · pub struct QueryRowsResult { /* private fields */ }
Expand description
Enables deserialization of rows received from the database in a QueryResult
.
Upon creation, it deserializes result metadata and allocates it.
This struct provides generic methods which enable typed access to the data, by deserializing rows on the fly to the type provided as a type parameter. Those methods are:
- rows() - for iterating through rows,
- first_row() and maybe_first_row() - for accessing the first row,
- single_row() - for accessing the first row, additionally asserting that it’s the only one in the response.
let rows_result = query_result.into_rows_result()?;
let mut rows_iter = rows_result.rows::<(i32, &str)>()?;
while let Some((num, text)) = rows_iter.next().transpose()? {
// do something with `num` and `text``
}
Ok(())
Implementations§
source§impl QueryRowsResult
impl QueryRowsResult
sourcepub fn tracing_id(&self) -> Option<Uuid>
pub fn tracing_id(&self) -> Option<Uuid>
Tracing ID associated with this CQL request.
sourcepub fn rows_bytes_size(&self) -> usize
pub fn rows_bytes_size(&self) -> usize
Returns the size of the serialized rows.
sourcepub fn column_specs(&self) -> ColumnSpecs<'_>
pub fn column_specs(&self) -> ColumnSpecs<'_>
Returns column specifications.
sourcepub fn rows<'frame, R: DeserializeRow<'frame, 'frame>>(
&'frame self,
) -> Result<TypedRowIterator<'frame, 'frame, R>, RowsError>
pub fn rows<'frame, R: DeserializeRow<'frame, 'frame>>( &'frame self, ) -> Result<TypedRowIterator<'frame, 'frame, R>, RowsError>
Returns an iterator over the received rows.
Returns an error if the rows in the response are of incorrect type.
sourcepub fn maybe_first_row<'frame, R: DeserializeRow<'frame, 'frame>>(
&'frame self,
) -> Result<Option<R>, MaybeFirstRowError>
pub fn maybe_first_row<'frame, R: DeserializeRow<'frame, 'frame>>( &'frame self, ) -> Result<Option<R>, MaybeFirstRowError>
Returns Option<R>
containing the first row of the result.
Fails when the the rows in the response are of incorrect type, or when the deserialization fails.
sourcepub fn first_row<'frame, R: DeserializeRow<'frame, 'frame>>(
&'frame self,
) -> Result<R, FirstRowError>
pub fn first_row<'frame, R: DeserializeRow<'frame, 'frame>>( &'frame self, ) -> Result<R, FirstRowError>
Returns the first row of the received result.
When the first row is not available, returns an error. Fails when the the rows in the response are of incorrect type, or when the deserialization fails.
sourcepub fn single_row<'frame, R: DeserializeRow<'frame, 'frame>>(
&'frame self,
) -> Result<R, SingleRowError>
pub fn single_row<'frame, R: DeserializeRow<'frame, 'frame>>( &'frame self, ) -> Result<R, SingleRowError>
Returns the only received row.
Fails if the result is anything else than a single row. Fails when the the rows in the response are of incorrect type, or when the deserialization fails.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for QueryRowsResult
impl RefUnwindSafe for QueryRowsResult
impl Send for QueryRowsResult
impl Sync for QueryRowsResult
impl Unpin for QueryRowsResult
impl UnwindSafe for QueryRowsResult
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> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more