pub struct QueryScalar<'q, DB: Database, O, A> { /* private fields */ }
Expand description

Raw SQL query with bind parameters, mapped to a concrete type using FromRow on (O,). Returned from query_scalar.

Implementations§

source§

impl<'q, DB: Database, O> QueryScalar<'q, DB, O, <DB as HasArguments<'q>>::Arguments>

source

pub fn bind<T: 'q + Send + Encode<'q, DB> + Type<DB>>(self, value: T) -> Self

Bind a value for use with this SQL query.

See Query::bind.

source§

impl<'q, DB, O, A> QueryScalar<'q, DB, O, A>where DB: Database + HasStatementCache,

source

pub fn persistent(self, value: bool) -> Self

If true, the statement will get prepared once and cached to the connection’s statement cache.

If queried once with the flag set to true, all subsequent queries matching the one with the flag will use the cached statement until the cache is cleared.

Default: true.

source§

impl<'q, DB, O, A> QueryScalar<'q, DB, O, A>where DB: Database, O: Send + Unpin, A: 'q + IntoArguments<'q, DB>, (O,): Send + Unpin + for<'r> FromRow<'r, DB::Row>,

source

pub fn fetch<'e, 'c: 'e, E>( self, executor: E ) -> BoxStream<'e, Result<O, Error>>where E: 'e + Executor<'c, Database = DB>, DB: 'e, A: 'e, O: 'e, 'q: 'e,

Execute the query and return the generated results as a stream.

source

pub fn fetch_many<'e, 'c: 'e, E>( self, executor: E ) -> BoxStream<'e, Result<Either<DB::QueryResult, O>, Error>>where E: 'e + Executor<'c, Database = DB>, DB: 'e, A: 'e, O: 'e, 'q: 'e,

Execute multiple queries and return the generated results as a stream from each query, in a stream.

source

pub async fn fetch_all<'e, 'c: 'e, E>( self, executor: E ) -> Result<Vec<O>, Error>where E: 'e + Executor<'c, Database = DB>, DB: 'e, (O,): 'e, A: 'e, 'q: 'e,

Execute the query and return all the generated results, collected into a Vec.

source

pub async fn fetch_one<'e, 'c: 'e, E>(self, executor: E) -> Result<O, Error>where E: 'e + Executor<'c, Database = DB>, DB: 'e, O: 'e, A: 'e, 'q: 'e,

Execute the query and returns exactly one row.

source

pub async fn fetch_optional<'e, 'c: 'e, E>( self, executor: E ) -> Result<Option<O>, Error>where E: 'e + Executor<'c, Database = DB>, DB: 'e, O: 'e, A: 'e, 'q: 'e,

Execute the query and returns at most one row.

Trait Implementations§

source§

impl<'q, DB: Database, O: Send, A> Execute<'q, DB> for QueryScalar<'q, DB, O, A>where A: 'q + IntoArguments<'q, DB> + Send,

source§

fn sql(&self) -> &'q str

Gets the SQL that will be executed.
source§

fn statement(&self) -> Option<&<DB as HasStatement<'q>>::Statement>

Gets the previously cached statement, if available.
source§

fn take_arguments(&mut self) -> Option<<DB as HasArguments<'q>>::Arguments>

Returns the arguments to be bound against the query string. Read more
source§

fn persistent(&self) -> bool

Returns true if the statement should be cached.

Auto Trait Implementations§

§

impl<'q, DB, O, A> RefUnwindSafe for QueryScalar<'q, DB, O, A>where A: RefUnwindSafe, DB: RefUnwindSafe, O: RefUnwindSafe, <DB as HasStatement<'q>>::Statement: RefUnwindSafe,

§

impl<'q, DB, O, A> Send for QueryScalar<'q, DB, O, A>where A: Send, O: Send,

§

impl<'q, DB, O, A> Sync for QueryScalar<'q, DB, O, A>where A: Sync, DB: Sync, O: Sync,

§

impl<'q, DB, O, A> Unpin for QueryScalar<'q, DB, O, A>where A: Unpin, DB: Unpin, O: Unpin,

§

impl<'q, DB, O, A> UnwindSafe for QueryScalar<'q, DB, O, A>where A: UnwindSafe, DB: UnwindSafe, O: UnwindSafe, <DB as HasStatement<'q>>::Statement: RefUnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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<T> for T

§

type Output = T

Should always be Self
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

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

§

fn vzip(self) -> V