pub struct QueryAs<T> { /* private fields */ }Expand description
A compiled, type-safe query. Created by the query_as! macro.
Call .fetch_all(&conn), .fetch_one(&conn), or .fetch_optional(&conn)
to execute it.
Implementations§
Source§impl<T: FromRow> QueryAs<T>
impl<T: FromRow> QueryAs<T>
Sourcepub fn new(sql: &str, params: &[&dyn Debug]) -> Self
pub fn new(sql: &str, params: &[&dyn Debug]) -> Self
Construct a new QueryAs. Called by the query_as! macro; not intended
for direct use.
params accepts &dyn std::fmt::Debug so the macro can pass any bind
arguments through — the actual typed binding will be tightened in W3.
Sourcepub fn fetch_all(self, conn: &Connection) -> Result<Vec<T>>
pub fn fetch_all(self, conn: &Connection) -> Result<Vec<T>>
Execute the query and collect all rows into a Vec<T>.
§Errors
Returns a hyperdb_api::Error on connection failure, SQL error, or
row-mapping failure.
Sourcepub fn fetch_one(self, conn: &Connection) -> Result<T>
pub fn fetch_one(self, conn: &Connection) -> Result<T>
Execute the query and return exactly one row.
§Errors
Returns Error::Conversion if the query returns zero rows.
Returns a hyperdb_api::Error on connection or SQL failure.
Sourcepub fn fetch_optional(self, conn: &Connection) -> Result<Option<T>>
pub fn fetch_optional(self, conn: &Connection) -> Result<Option<T>>
Execute the query and return Some(row) for the first row, or None
if the query returns zero rows.
§Errors
Returns a hyperdb_api::Error on connection or SQL failure.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for QueryAs<T>
impl<T> RefUnwindSafe for QueryAs<T>
impl<T> Send for QueryAs<T>
impl<T> Sync for QueryAs<T>
impl<T> Unpin for QueryAs<T>
impl<T> UnsafeUnpin for QueryAs<T>
impl<T> UnwindSafe for QueryAs<T>
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
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request