Struct scylla::transport::legacy_query_result::LegacyQueryResult
source · #[non_exhaustive]pub struct LegacyQueryResult {
pub rows: Option<Vec<Row>>,
pub warnings: Vec<String>,
pub tracing_id: Option<Uuid>,
pub serialized_size: usize,
/* private fields */
}
Expand description
Result of a single query
Contains all rows returned by the database and some more information
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.rows: Option<Vec<Row>>
Rows returned by the database.
Queries like SELECT
will have Some(Vec)
, while queries like INSERT
will have None
.
Can contain an empty Vec.
warnings: Vec<String>
Warnings returned by the database
tracing_id: Option<Uuid>
CQL Tracing uuid - can only be Some if tracing is enabled for this query
serialized_size: usize
The original size of the serialized rows in request
Implementations§
source§impl LegacyQueryResult
impl LegacyQueryResult
sourcepub fn rows_num(&self) -> Result<usize, RowsExpectedError>
pub fn rows_num(&self) -> Result<usize, RowsExpectedError>
Returns the number of received rows.
Fails when the query isn’t of a type that could return rows, same as rows()
.
sourcepub fn rows(self) -> Result<Vec<Row>, RowsExpectedError>
pub fn rows(self) -> Result<Vec<Row>, RowsExpectedError>
Returns the received rows when present.
If LegacyQueryResult.rows
is None
, which means that this query is not supposed to return rows (e.g INSERT
), returns an error.
Can return an empty Vec
.
sourcepub fn rows_typed<RowT: FromRow>(
self,
) -> Result<TypedRowIter<RowT>, RowsExpectedError>
pub fn rows_typed<RowT: FromRow>( self, ) -> Result<TypedRowIter<RowT>, RowsExpectedError>
Returns the received rows parsed as the given type.
Equal to rows()?.into_typed()
.
Fails when the query isn’t of a type that could return rows, same as rows()
.
sourcepub fn result_not_rows(&self) -> Result<(), RowsNotExpectedError>
pub fn result_not_rows(&self) -> Result<(), RowsNotExpectedError>
Returns Ok
for a result of a query that shouldn’t contain any rows.
Will return Ok
for INSERT
result, but a SELECT
result, even an empty one, will cause an error.
Opposite of rows()
.
sourcepub fn rows_or_empty(self) -> Vec<Row>
pub fn rows_or_empty(self) -> Vec<Row>
Returns rows when LegacyQueryResult.rows
is Some
, otherwise an empty Vec.
Equal to rows().unwrap_or_default()
.
sourcepub fn rows_typed_or_empty<RowT: FromRow>(self) -> TypedRowIter<RowT> ⓘ
pub fn rows_typed_or_empty<RowT: FromRow>(self) -> TypedRowIter<RowT> ⓘ
Returns rows parsed as the given type.
When LegacyQueryResult.rows
is None
, returns 0 rows.
Equal to rows_or_empty().into_typed::<RowT>()
.
sourcepub fn first_row(self) -> Result<Row, FirstRowError>
pub fn first_row(self) -> Result<Row, FirstRowError>
Returns first row from the received rows.
When the first row is not available, returns an error.
sourcepub fn first_row_typed<RowT: FromRow>(self) -> Result<RowT, FirstRowTypedError>
pub fn first_row_typed<RowT: FromRow>(self) -> Result<RowT, FirstRowTypedError>
Returns first row from the received rows parsed as the given type.
When the first row is not available, returns an error.
sourcepub fn maybe_first_row(self) -> Result<Option<Row>, RowsExpectedError>
pub fn maybe_first_row(self) -> Result<Option<Row>, RowsExpectedError>
Returns Option<RowT>
containing the first of a result.
Fails when the query isn’t of a type that could return rows, same as rows()
.
sourcepub fn maybe_first_row_typed<RowT: FromRow>(
self,
) -> Result<Option<RowT>, MaybeFirstRowTypedError>
pub fn maybe_first_row_typed<RowT: FromRow>( self, ) -> Result<Option<RowT>, MaybeFirstRowTypedError>
Returns Option<RowT>
containing the first of a result.
Fails when the query isn’t of a type that could return rows, same as rows()
.
sourcepub fn single_row(self) -> Result<Row, SingleRowError>
pub fn single_row(self) -> Result<Row, SingleRowError>
Returns the only received row.
Fails if the result is anything else than a single row.\
sourcepub fn single_row_typed<RowT: FromRow>(
self,
) -> Result<RowT, SingleRowTypedError>
pub fn single_row_typed<RowT: FromRow>( self, ) -> Result<RowT, SingleRowTypedError>
Returns the only received row parsed as the given type.
Fails if the result is anything else than a single row.\
sourcepub fn col_specs(&self) -> &[ColumnSpec<'_>]
pub fn col_specs(&self) -> &[ColumnSpec<'_>]
Returns column specifications.
sourcepub fn get_column_spec<'a>(
&'a self,
name: &str,
) -> Option<(usize, &'a ColumnSpec<'a>)>
pub fn get_column_spec<'a>( &'a self, name: &str, ) -> Option<(usize, &'a ColumnSpec<'a>)>
Returns a column specification for a column with given name, or None if not found
Trait Implementations§
source§impl Debug for LegacyQueryResult
impl Debug for LegacyQueryResult
source§impl Default for LegacyQueryResult
impl Default for LegacyQueryResult
source§fn default() -> LegacyQueryResult
fn default() -> LegacyQueryResult
Auto Trait Implementations§
impl !Freeze for LegacyQueryResult
impl RefUnwindSafe for LegacyQueryResult
impl Send for LegacyQueryResult
impl Sync for LegacyQueryResult
impl Unpin for LegacyQueryResult
impl UnwindSafe for LegacyQueryResult
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