Struct mysql_async::QueryResult[][src]

pub struct QueryResult<'a, 't: 'a, P> { /* fields omitted */ }

Result of a query or statement execution.

Represents an asynchronous query result, that may not be fully consumed.

Note

Unconsumed query results are dropped implicitly when corresponding connection is dropped or queried. Also note, that in this case all remaining errors will be emitted to the caller:

use mysql_async::*;
use mysql_async::prelude::*;
let mut conn = Conn::new(get_opts()).await?;

// second result set will contain an error,
// but the first result set is ok, so this line will pass
conn.query_iter("DO 1; BLABLA;").await?;
// `QueryResult` was dropped withot being consumed

// driver must cleanup any unconsumed result to perform another query on `conn`,
// so this operation will be performed implicitly, but the unconsumed result
// contains an error claiming about 'BLABLA', so this error will be emitted here:
assert!(conn.query_iter("DO 1").await.unwrap_err().to_string().contains("BLABLA"));

Implementations

impl<'a, 't: 'a, P> QueryResult<'a, 't, P> where
    P: Protocol
[src]

pub fn new<T: Into<Connection<'a, 't>>>(conn: T) -> Self[src]

pub fn is_empty(&self) -> bool[src]

true if there are no more rows nor result sets in this query.

pub async fn next(&mut self) -> Result<Option<Row>>[src]

pub fn last_insert_id(&self) -> Option<u64>[src]

Last insert id, if any.

pub fn affected_rows(&self) -> u64[src]

Number of affected rows as reported by the server, or 0.

pub fn info(&self) -> Cow<'_, str>[src]

Text information as reported by the server, or an empty string.

pub fn warnings(&self) -> u16[src]

Number of warnings as reported by the server, or 0.

pub async fn collect<R>(&mut self) -> Result<Vec<R>> where
    R: FromRow + Send + 'static, 
[src]

Collects the current result set of this query result.

It is parametrized by R and internally calls R::from_row(Row) on each row.

It will collect rows up to a neares 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.

Panic

It'll panic if any row isn't convertible to R (i.e. programmer error or unknown schema).

pub async fn try_collect<R>(
    &mut self
) -> Result<Vec<StdResult<R, FromRowError>>> where
    R: FromRow + Send + 'static, 
[src]

Collects the current result set of this query result.

It works the same way as QueryResult::collect but won't panic if row isn't convertible to R.

pub async fn collect_and_drop<R>(self) -> Result<Vec<R>> where
    R: FromRow + Send + 'static, 
[src]

Collects the current result set of this query result and drops everything else.

Panic

It'll panic if any row isn't convertible to R (i.e. programmer error or unknown schema).

pub async fn try_collect_and_drop<R>(
    self
) -> Result<Vec<StdResult<R, FromRowError>>> where
    R: FromRow + Send + 'static, 
[src]

Collects the current result set of this query result and drops everything else.

It works the same way as QueryResult::collect_and_drop but won't panic if row isn't convertible to R.

pub async fn for_each<F>(&mut self, fun: F) -> Result<()> where
    F: FnMut(Row), 
[src]

Executes fun on every row of the current result set.

It will stop on the nearest result set boundary (see QueryResult::collect docs).

pub async fn for_each_and_drop<F>(self, fun: F) -> Result<()> where
    F: FnMut(Row), 
[src]

Executes fun on every row of the current result set and drops everything else.

pub async fn map<F, U>(&mut self, fun: F) -> Result<Vec<U>> where
    F: FnMut(Row) -> U, 
[src]

Maps every row of the current result set to U using fun.

It will stop on the nearest result set boundary (see QueryResult::collect docs).

pub async fn map_and_drop<F, U>(self, fun: F) -> Result<Vec<U>> where
    F: FnMut(Row) -> U, 
[src]

Map every row of the current result set to U using fun and drops everything else.

pub async fn reduce<T, F, U>(&mut self, init: U, fun: F) -> Result<U> where
    F: FnMut(U, T) -> U,
    T: FromRow + Send + 'static, 
[src]

Reduces rows of the current result set to U using fun.

It will stop on the nearest result set boundary (see QueryResult::collect docs).

pub async fn reduce_and_drop<T, F, U>(self, init: U, fun: F) -> Result<U> where
    F: FnMut(U, T) -> U,
    T: FromRow + Send + 'static, 
[src]

Reduces rows of the current result set to U using fun and drops everything else.

pub async fn drop_result(self) -> Result<()>[src]

Drops this query result.

pub fn columns_ref(&self) -> &[Column][src]

Returns a reference to a columns list of this query result.

Empty list means that this result set was never meant to contain rows.

pub fn columns(&self) -> Option<Arc<[Column]>>[src]

Returns a copy of a columns list of this query result.

Trait Implementations

impl<'a, 't: 'a, P: Debug> Debug for QueryResult<'a, 't, P>[src]

Auto Trait Implementations

impl<'a, 't, P> !RefUnwindSafe for QueryResult<'a, 't, P>[src]

impl<'a, 't, P> Send for QueryResult<'a, 't, P> where
    P: Send
[src]

impl<'a, 't, P> Sync for QueryResult<'a, 't, P> where
    P: Sync
[src]

impl<'a, 't, P> Unpin for QueryResult<'a, 't, P> where
    P: Unpin,
    't: 'a, 
[src]

impl<'a, 't, P> !UnwindSafe for QueryResult<'a, 't, P>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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