Struct scylla::transport::query_result::QueryResult
source · pub struct QueryResult { /* private fields */ }
Expand description
Result of a single request to the database. It represents any kind of Result frame.
The received rows and metadata, which are present if the frame is of Result:Rows kind,
are kept in a raw binary form. To deserialize and access them, transform QueryResult
to QueryRowsResult by calling QueryResult::into_rows_result.
NOTE: this is a result of a single CQL request. If you use paging for your query, this will contain exactly one page.
Implementations§
source§impl QueryResult
impl QueryResult
sourcepub fn tracing_id(&self) -> Option<Uuid>
pub fn tracing_id(&self) -> Option<Uuid>
Tracing ID associated with this CQL request.
sourcepub fn result_not_rows(&self) -> Result<(), ResultNotRowsError>
pub fn result_not_rows(&self) -> Result<(), ResultNotRowsError>
Returns Ok
for a request’s result 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 QueryResult::into_rows_result.
sourcepub fn into_rows_result(self) -> Result<QueryRowsResult, IntoRowsResultError>
pub fn into_rows_result(self) -> Result<QueryRowsResult, IntoRowsResultError>
Transforms itself into the Rows result type to enable deserializing rows. Deserializes result metadata and allocates it.
Returns an error if the response is not of Rows kind or metadata deserialization failed.
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(())
If the response is not of Rows kind, the original QueryResult
(self) is
returned back to the user in the error type. See IntoRowsResultError
documentation.
let err = non_rows_query_result.into_rows_result().unwrap_err();
match err {
IntoRowsResultError::ResultNotRows(query_result) => {
// do something with original `query_result`
}
_ => {
// deserialization failed - query result is not recovered
}
}
Ok(())
sourcepub fn into_legacy_result(
self,
) -> Result<LegacyQueryResult, IntoLegacyQueryResultError>
👎Deprecated since 0.15.0: Legacy deserialization API is inefficient and is going to be removed soon
pub fn into_legacy_result( self, ) -> Result<LegacyQueryResult, IntoLegacyQueryResultError>
Transforms itself into the legacy result type, by eagerly deserializing rows into the Row type. This is inefficient, and should only be used during transition period to the new API.
Trait Implementations§
source§impl Clone for QueryResult
impl Clone for QueryResult
source§fn clone(&self) -> QueryResult
fn clone(&self) -> QueryResult
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl !Freeze for QueryResult
impl RefUnwindSafe for QueryResult
impl Send for QueryResult
impl Sync for QueryResult
impl Unpin for QueryResult
impl UnwindSafe for QueryResult
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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