Struct Query

Source
pub struct Query<'a, T = Vec<Row>>(pub String, _, _);
Expand description

A struct for storing a complete query along with parameters and output type.

Depending on the output type, Executable is implemented differently to allow for easy parsing.

Tuple Fields§

§0: String

Implementations§

Source§

impl<'a, T> Query<'a, T>

Source

pub fn new(stmt: String, params: Vec<&'a (dyn ToSql + Sync)>) -> Query<'a, T>

Create a new query by passing a raw statement as well as parameters.

Trait Implementations§

Source§

impl<'a, T> Default for Query<'a, T>

Source§

fn default() -> Self

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

impl<'a, T> Executable for Query<'a, Option<T>>
where T: TryFrom<Row, Error = Error> + Send + Sync,

Source§

type Output = Option<T>

What output should this query result in?
Source§

fn exec_with<'life0, 'async_trait>( &'life0 self, client: impl 'async_trait + Executor + Send + Sync, ) -> Pin<Box<dyn Future<Output = Result<Self::Output, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Execute the query given any viable Executor
Source§

fn exec<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Self::Output, Error>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait,

The actual function for executing a query.
Source§

impl<'a, T> Executable for Query<'a, Vec<T>>
where T: TryFrom<Row, Error = Error> + Send + Sync,

Source§

type Output = Vec<T>

What output should this query result in?
Source§

fn exec_with<'life0, 'async_trait>( &'life0 self, client: impl 'async_trait + Executor + Send + Sync, ) -> Pin<Box<dyn Future<Output = Result<Self::Output, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Execute the query given any viable Executor
Source§

fn exec<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Self::Output, Error>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait,

The actual function for executing a query.
Source§

impl<'a> Executable for Query<'a, u64>

Source§

type Output = u64

What output should this query result in?
Source§

fn exec_with<'life0, 'async_trait>( &'life0 self, client: impl 'async_trait + Executor + Send + Sync, ) -> Pin<Box<dyn Future<Output = Result<Self::Output, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Execute the query given any viable Executor
Source§

fn exec<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Self::Output, Error>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait,

The actual function for executing a query.
Source§

impl<'a, T> IntoFuture for Query<'a, T>
where Query<'a, T>: Executable<Output = T>, T: Sync + Send + 'a,

Implement IntoFuture for Query so that any executable Query may be executed by calling .await.

Source§

type IntoFuture = Pin<Box<dyn Future<Output = <Query<'a, T> as IntoFuture>::Output> + 'a>>

Which kind of future are we turning this into?
Source§

type Output = Result<T, Error>

The output that the future will produce on completion.
Source§

fn into_future(self) -> Self::IntoFuture

Creates a future from a value. Read more

Auto Trait Implementations§

§

impl<'a, T> Freeze for Query<'a, T>

§

impl<'a, T = Vec<Row>> !RefUnwindSafe for Query<'a, T>

§

impl<'a, T> Send for Query<'a, T>
where T: Send,

§

impl<'a, T> Sync for Query<'a, T>
where T: Sync,

§

impl<'a, T> Unpin for Query<'a, T>
where T: Unpin,

§

impl<'a, T = Vec<Row>> !UnwindSafe for Query<'a, T>

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, 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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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