pub struct QueryResult { /* private fields */ }Expand description
The result of a query execution.
QueryResult contains the rows returned by a SELECT query, along with
metadata about the result set.
§Examples
Iterate over results:
ⓘ
let results = db.query("SELECT * FROM users")?;
for row in &results {
let name: &str = row.get("name")?;
println!("User: {}", name);
}Access by index:
ⓘ
if let Some(row) = results.get(0) {
let name: &str = row.get(0)?;
}Implementations§
Source§impl QueryResult
impl QueryResult
Sourcepub fn new(columns: Vec<String>, rows: Vec<QueryRow>) -> Self
pub fn new(columns: Vec<String>, rows: Vec<QueryRow>) -> Self
Create a query result with the given columns and rows.
Sourcepub fn from_result_set(result_set: ResultSet) -> Self
pub fn from_result_set(result_set: ResultSet) -> Self
Create a query result from the query engine’s result set.
Sourcepub fn num_columns(&self) -> usize
pub fn num_columns(&self) -> usize
Returns the number of columns.
Sourcepub fn column_index(&self, name: &str) -> Option<usize>
pub fn column_index(&self, name: &str) -> Option<usize>
Get the column index for a column name.
Trait Implementations§
Source§impl Clone for QueryResult
impl Clone for QueryResult
Source§fn clone(&self) -> QueryResult
fn clone(&self) -> QueryResult
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for QueryResult
impl Debug for QueryResult
Source§impl<'a> IntoIterator for &'a QueryResult
impl<'a> IntoIterator for &'a QueryResult
Auto Trait Implementations§
impl Freeze for QueryResult
impl RefUnwindSafe for QueryResult
impl Send for QueryResult
impl Sync for QueryResult
impl Unpin for QueryResult
impl UnwindSafe for QueryResult
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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