Struct scylla::transport::query_result::QueryResult

source ·
#[non_exhaustive]
pub struct QueryResult { pub rows: Option<Vec<Row>>, pub warnings: Vec<String>, pub tracing_id: Option<Uuid>, pub paging_state: Option<Bytes>, pub col_specs: Vec<ColumnSpec>, pub serialized_size: usize, }
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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional 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

§paging_state: Option<Bytes>

Paging state returned from the server

§col_specs: Vec<ColumnSpec>

Column specification returned from the server

§serialized_size: usize

The original size of the serialized rows in request

Implementations§

source§

impl QueryResult

source

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().

source

pub fn rows(self) -> Result<Vec<Row>, RowsExpectedError>

Returns the received rows when present.
If QueryResult.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.

source

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().

source

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().

source

pub fn rows_or_empty(self) -> Vec<Row>

Returns rows when QueryResult.rows is Some, otherwise an empty Vec.
Equal to rows().unwrap_or_default().

source

pub fn rows_typed_or_empty<RowT: FromRow>(self) -> TypedRowIter<RowT>

Returns rows parsed as the given type.
When QueryResult.rows is None, returns 0 rows.
Equal to rows_or_empty().into_typed::<RowT>().

source

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.

source

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.

source

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().

source

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().

source

pub fn single_row(self) -> Result<Row, SingleRowError>

Returns the only received row.
Fails if the result is anything else than a single row.\

source

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.\

source

pub fn get_column_spec<'a>( &'a self, name: &str ) -> Option<(usize, &'a ColumnSpec)>

Returns a column specification for a column with given name, or None if not found

Trait Implementations§

source§

impl Debug for QueryResult

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for QueryResult

source§

fn default() -> QueryResult

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more