pub struct Query<'r, C: Connection> { /* private fields */ }
Expand description
A query future
Implementations§
Source§impl<'r, C> Query<'r, C>where
C: Connection,
impl<'r, C> Query<'r, C>where
C: Connection,
Sourcepub fn into_owned(self) -> Query<'static, C>
pub fn into_owned(self) -> Query<'static, C>
Converts to an owned type which can easily be moved to a different thread
Source§impl<C> Query<'_, C>where
C: Connection,
impl<C> Query<'_, C>where
C: Connection,
Sourcepub const fn with_stats(self) -> WithStats<Self>
pub const fn with_stats(self) -> WithStats<Self>
Return query statistics along with its results
Sourcepub fn bind(self, bindings: impl Serialize + 'static) -> Self
pub fn bind(self, bindings: impl Serialize + 'static) -> Self
Binds a parameter or parameters to a query
§Examples
Binding a key/value tuple
let response = db.query("CREATE user SET name = $name")
.bind(("name", "John Doe"))
.await?;
Binding an object
use serde::Serialize;
#[derive(Serialize)]
struct User<'a> {
name: &'a str,
}
let response = db.query("CREATE user SET name = $name")
.bind(User {
name: "John Doe",
})
.await?;
Trait Implementations§
Source§impl<'r, Client> IntoFuture for Query<'r, Client>where
Client: Connection,
impl<'r, Client> IntoFuture for Query<'r, Client>where
Client: Connection,
Source§type IntoFuture = Pin<Box<dyn Future<Output = <Query<'r, Client> as IntoFuture>::Output> + Sync + Send + 'r>>
type IntoFuture = Pin<Box<dyn Future<Output = <Query<'r, Client> as IntoFuture>::Output> + Sync + Send + 'r>>
Which kind of future are we turning this into?
Source§fn into_future(self) -> Self::IntoFuture
fn into_future(self) -> Self::IntoFuture
Creates a future from a value. Read more
Auto Trait Implementations§
impl<'r, C> Freeze for Query<'r, C>
impl<'r, C> !RefUnwindSafe for Query<'r, C>
impl<'r, C> Send for Query<'r, C>
impl<'r, C> Sync for Query<'r, C>
impl<'r, C> Unpin for Query<'r, C>where
C: Unpin,
impl<'r, C> !UnwindSafe for Query<'r, C>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more