Struct mysql_async::QueryResult
source · pub struct QueryResult<T, P>(_);
Expand description
Result of a query or statement execution.
Implementations§
source§impl<T, P> QueryResult<T, P>where
P: Protocol,
P: Send + 'static,
T: ConnectionLike,
T: Sized + Send + 'static,
impl<T, P> QueryResult<T, P>where
P: Protocol,
P: Send + 'static,
T: ConnectionLike,
T: Sized + Send + 'static,
sourcepub fn last_insert_id(&self) -> Option<u64>
pub fn last_insert_id(&self) -> Option<u64>
Last insert id (if not 0).
sourcepub fn affected_rows(&self) -> u64
pub fn affected_rows(&self) -> u64
Value of affected_rows
returned from a server.
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
true
if there is no more rows nor result sets in this query.
One could use it to check if there is more than one result set in this query result.
sourcepub fn collect<R>(self) -> impl MyFuture<(Self, Vec<R>)>where
R: FromRow,
R: Send + 'static,
pub fn collect<R>(self) -> impl MyFuture<(Self, Vec<R>)>where
R: FromRow,
R: Send + 'static,
Returns future that collects result set of this query result.
It is parametrized by R
and internally calls R::from_row(Row)
on each row.
It will stop collecting on result set boundary. This means that you should call collect
as many times as result sets in your query result. For example query
SELECT 'foo'; SELECT 'foo', 'bar';
will produce QueryResult
with two result sets in it.
One can use QueryResult::is_empty
to make sure that there is no more result sets.
sourcepub fn collect_and_drop<R>(self) -> impl MyFuture<(T, Vec<R>)>where
R: FromRow,
R: Send + 'static,
pub fn collect_and_drop<R>(self) -> impl MyFuture<(T, Vec<R>)>where
R: FromRow,
R: Send + 'static,
Returns future that collects result set of a query result and drops everything else.
It will resolve to a pair of wrapped Queryable
and collected result set.
sourcepub fn for_each<F>(
self,
fun: F
) -> Either<FutureResult<Self, Error>, ForEach<T, P, F>>where
F: FnMut(Row),
pub fn for_each<F>(
self,
fun: F
) -> Either<FutureResult<Self, Error>, ForEach<T, P, F>>where
F: FnMut(Row),
Returns future that will execute fun
on every row of current result set.
It will stop on result set boundary (see QueryResult::collect
docs).
sourcepub fn for_each_and_drop<F>(self, fun: F) -> ForEachAndDrop<Self, T, P, F>where
F: FnMut(Row),
pub fn for_each_and_drop<F>(self, fun: F) -> ForEachAndDrop<Self, T, P, F>where
F: FnMut(Row),
Returns future that will execute fun
on every row of current result set and drop
everything else. It will resolve to a wrapped Queryable
.
sourcepub fn map<F, U>(
self,
fun: F
) -> Either<FutureResult<(Self, Vec<U>), Error>, Map<T, P, F, U>>where
F: FnMut(Row) -> U,
pub fn map<F, U>(
self,
fun: F
) -> Either<FutureResult<(Self, Vec<U>), Error>, Map<T, P, F, U>>where
F: FnMut(Row) -> U,
Returns future that will map every row of current result set to U
using fun
.
It will stop on result set boundary (see QueryResult::collect
docs).
sourcepub fn map_and_drop<F, U>(self, fun: F) -> MapAndDrop<Self, T, P, F, U>where
F: FnMut(Row) -> U,
pub fn map_and_drop<F, U>(self, fun: F) -> MapAndDrop<Self, T, P, F, U>where
F: FnMut(Row) -> U,
Returns future that will map every row of current result set to U
using fun
and drop
everything else. It will resolve to a pair of wrapped Queryable
and mapped result set.
sourcepub fn reduce<F, U>(
self,
init: U,
fun: F
) -> Either<FutureResult<(Self, U), Error>, Reduce<T, P, F, U>>where
F: FnMut(U, Row) -> U,
pub fn reduce<F, U>(
self,
init: U,
fun: F
) -> Either<FutureResult<(Self, U), Error>, Reduce<T, P, F, U>>where
F: FnMut(U, Row) -> U,
Returns future that will reduce rows of current result set to U
using fun
.
It will stop on result set boundary (see QueryResult::collect
docs).
sourcepub fn reduce_and_drop<F, U>(
self,
init: U,
fun: F
) -> ReduceAndDrop<Self, T, P, F, U>where
F: FnMut(U, Row) -> U,
pub fn reduce_and_drop<F, U>(
self,
init: U,
fun: F
) -> ReduceAndDrop<Self, T, P, F, U>where
F: FnMut(U, Row) -> U,
Returns future that will reduce rows of current result set to U
using fun
and drop
everything else. It will resolve to a pair of wrapped Queryable
and U
.
sourcepub fn drop_result(self) -> impl MyFuture<T>
pub fn drop_result(self) -> impl MyFuture<T>
Returns future that will drop this query result end resolve to a wrapped Queryable
.
sourcepub fn columns_ref(&self) -> &[Column]
pub fn columns_ref(&self) -> &[Column]
Returns reference to columns in this query result.