pub trait Query: Send + Sized {
    type Protocol: Protocol;

    // Required method
    fn run<'a, 't: 'a, C>(
        self,
        conn: C
    ) -> BoxFuture<'a, Result<QueryResult<'a, 't, Self::Protocol>>>
       where Self: 'a,
             C: ToConnection<'a, 't> + 'a;

    // Provided methods
    fn first<'a, 't: 'a, T, C>(
        self,
        conn: C
    ) -> BoxFuture<'a, Result<Option<T>>>
       where Self: 'a,
             C: ToConnection<'a, 't> + 'a,
             T: FromRow + Send + 'static { ... }
    fn fetch<'a, 't: 'a, T, C>(self, conn: C) -> BoxFuture<'a, Result<Vec<T>>>
       where Self: 'a,
             C: ToConnection<'a, 't> + 'a,
             T: FromRow + Send + 'static { ... }
    fn reduce<'a, 't: 'a, T, U, F, C>(
        self,
        conn: C,
        init: U,
        next: F
    ) -> BoxFuture<'a, Result<U>>
       where Self: 'a,
             C: ToConnection<'a, 't> + 'a,
             F: FnMut(U, T) -> U + Send + 'a,
             T: FromRow + Send + 'static,
             U: Send + 'a { ... }
    fn map<'a, 't: 'a, T, U, F, C>(
        self,
        conn: C,
        map: F
    ) -> BoxFuture<'a, Result<Vec<U>>>
       where Self: 'a,
             C: ToConnection<'a, 't> + 'a,
             F: FnMut(T) -> U + Send + 'a,
             T: FromRow + Send + 'static,
             U: Send + 'a { ... }
    fn stream<'a, 't: 'a, T, C>(
        self,
        conn: C
    ) -> BoxFuture<'a, Result<ResultSetStream<'a, 'a, 't, T, Self::Protocol>>>
       where Self: 'a,
             Self::Protocol: Unpin,
             T: Unpin + FromRow + Send + 'static,
             C: ToConnection<'a, 't> + 'a { ... }
    fn ignore<'a, 't: 'a, C>(self, conn: C) -> BoxFuture<'a, Result<()>>
       where Self: 'a,
             C: ToConnection<'a, 't> + 'a { ... }
}
Expand description

MySql text query.

This trait covers the set of query* methods on the Queryable trait.

Example:

use mysql_async::*;
use mysql_async::prelude::*;
let pool = Pool::new(get_opts());

// text protocol query
let num: Option<u32> = "SELECT 42".first(&pool).await?;
assert_eq!(num, Some(42));

// binary protocol query (prepared statement)
let row: Option<(u32, String)> = "SELECT ?, ?".with((42, "foo")).first(&pool).await?;
assert_eq!(row.unwrap(), (42, "foo".into()));

Required Associated Types§

source

type Protocol: Protocol

Query protocol.

Required Methods§

source

fn run<'a, 't: 'a, C>( self, conn: C ) -> BoxFuture<'a, Result<QueryResult<'a, 't, Self::Protocol>>>
where Self: 'a, C: ToConnection<'a, 't> + 'a,

This method corresponds to Queryable::query_iter.

Provided Methods§

source

fn first<'a, 't: 'a, T, C>(self, conn: C) -> BoxFuture<'a, Result<Option<T>>>
where Self: 'a, C: ToConnection<'a, 't> + 'a, T: FromRow + Send + 'static,

This methods corresponds to Queryable::query_first.

source

fn fetch<'a, 't: 'a, T, C>(self, conn: C) -> BoxFuture<'a, Result<Vec<T>>>
where Self: 'a, C: ToConnection<'a, 't> + 'a, T: FromRow + Send + 'static,

This methods corresponds to Queryable::query.

source

fn reduce<'a, 't: 'a, T, U, F, C>( self, conn: C, init: U, next: F ) -> BoxFuture<'a, Result<U>>
where Self: 'a, C: ToConnection<'a, 't> + 'a, F: FnMut(U, T) -> U + Send + 'a, T: FromRow + Send + 'static, U: Send + 'a,

This methods corresponds to Queryable::query_fold.

source

fn map<'a, 't: 'a, T, U, F, C>( self, conn: C, map: F ) -> BoxFuture<'a, Result<Vec<U>>>
where Self: 'a, C: ToConnection<'a, 't> + 'a, F: FnMut(T) -> U + Send + 'a, T: FromRow + Send + 'static, U: Send + 'a,

This methods corresponds to Queryable::query_map.

source

fn stream<'a, 't: 'a, T, C>( self, conn: C ) -> BoxFuture<'a, Result<ResultSetStream<'a, 'a, 't, T, Self::Protocol>>>
where Self: 'a, Self::Protocol: Unpin, T: Unpin + FromRow + Send + 'static, C: ToConnection<'a, 't> + 'a,

Returns a stream over the first result set.

This method corresponds to QueryResult::stream_and_drop.

source

fn ignore<'a, 't: 'a, C>(self, conn: C) -> BoxFuture<'a, Result<()>>
where Self: 'a, C: ToConnection<'a, 't> + 'a,

This method corresponds to Queryable::query_drop.

Object Safety§

This trait is not object safe.

Implementors§