pub trait Queryable {
Show 23 methods
// Required methods
fn query_iter<Q: AsRef<str>>(
&mut self,
query: Q,
) -> Result<QueryResult<'_, '_, '_, Text>>;
fn prep<Q: AsRef<str>>(&mut self, query: Q) -> Result<Statement>;
fn close(&mut self, stmt: Statement) -> Result<()>;
fn exec_iter<S, P>(
&mut self,
stmt: S,
params: P,
) -> Result<QueryResult<'_, '_, '_, Binary>>
where S: AsStatement,
P: Into<Params>;
// Provided methods
fn query<T, Q>(&mut self, query: Q) -> Result<Vec<T>>
where Q: AsRef<str>,
T: FromRow { ... }
fn query_opt<T, Q>(
&mut self,
query: Q,
) -> Result<Vec<StdResult<T, FromRowError>>>
where Q: AsRef<str>,
T: FromRow { ... }
fn query_first<T, Q>(&mut self, query: Q) -> Result<Option<T>>
where Q: AsRef<str>,
T: FromRow { ... }
fn query_first_opt<T, Q>(
&mut self,
query: Q,
) -> Result<Option<StdResult<T, FromRowError>>>
where Q: AsRef<str>,
T: FromRow { ... }
fn query_map<T, F, Q, U>(&mut self, query: Q, f: F) -> Result<Vec<U>>
where Q: AsRef<str>,
T: FromRow,
F: FnMut(T) -> U { ... }
fn query_map_opt<T, F, Q, U>(&mut self, query: Q, f: F) -> Result<Vec<U>>
where Q: AsRef<str>,
T: FromRow,
F: FnMut(StdResult<T, FromRowError>) -> U { ... }
fn query_fold<T, F, Q, U>(&mut self, query: Q, init: U, f: F) -> Result<U>
where Q: AsRef<str>,
T: FromRow,
F: FnMut(U, T) -> U { ... }
fn query_fold_opt<T, F, Q, U>(
&mut self,
query: Q,
init: U,
f: F,
) -> Result<U>
where Q: AsRef<str>,
T: FromRow,
F: FnMut(U, StdResult<T, FromRowError>) -> U { ... }
fn query_drop<Q>(&mut self, query: Q) -> Result<()>
where Q: AsRef<str> { ... }
fn exec_batch<S, P, I>(&mut self, stmt: S, params: I) -> Result<()>
where Self: Sized,
S: AsStatement,
P: Into<Params>,
I: IntoIterator<Item = P> { ... }
fn exec<T, S, P>(&mut self, stmt: S, params: P) -> Result<Vec<T>>
where S: AsStatement,
P: Into<Params>,
T: FromRow { ... }
fn exec_opt<T, S, P>(
&mut self,
stmt: S,
params: P,
) -> Result<Vec<StdResult<T, FromRowError>>>
where S: AsStatement,
P: Into<Params>,
T: FromRow { ... }
fn exec_first<T, S, P>(&mut self, stmt: S, params: P) -> Result<Option<T>>
where S: AsStatement,
P: Into<Params>,
T: FromRow { ... }
fn exec_first_opt<T, S, P>(
&mut self,
stmt: S,
params: P,
) -> Result<Option<StdResult<T, FromRowError>>>
where S: AsStatement,
P: Into<Params>,
T: FromRow { ... }
fn exec_map<T, S, P, F, U>(
&mut self,
stmt: S,
params: P,
f: F,
) -> Result<Vec<U>>
where S: AsStatement,
P: Into<Params>,
T: FromRow,
F: FnMut(T) -> U { ... }
fn exec_map_opt<T, S, P, F, U>(
&mut self,
stmt: S,
params: P,
f: F,
) -> Result<Vec<U>>
where S: AsStatement,
P: Into<Params>,
T: FromRow,
F: FnMut(StdResult<T, FromRowError>) -> U { ... }
fn exec_fold<T, S, P, U, F>(
&mut self,
stmt: S,
params: P,
init: U,
f: F,
) -> Result<U>
where S: AsStatement,
P: Into<Params>,
T: FromRow,
F: FnMut(U, T) -> U { ... }
fn exec_fold_opt<T, S, P, U, F>(
&mut self,
stmt: S,
params: P,
init: U,
f: F,
) -> Result<U>
where S: AsStatement,
P: Into<Params>,
T: FromRow,
F: FnMut(U, StdResult<T, FromRowError>) -> U { ... }
fn exec_drop<S, P>(&mut self, stmt: S, params: P) -> Result<()>
where S: AsStatement,
P: Into<Params> { ... }
}Expand description
Queryable object.
Required Methods§
Sourcefn query_iter<Q: AsRef<str>>(
&mut self,
query: Q,
) -> Result<QueryResult<'_, '_, '_, Text>>
fn query_iter<Q: AsRef<str>>( &mut self, query: Q, ) -> Result<QueryResult<'_, '_, '_, Text>>
Perfoms text query.
Sourcefn prep<Q: AsRef<str>>(&mut self, query: Q) -> Result<Statement>
fn prep<Q: AsRef<str>>(&mut self, query: Q) -> Result<Statement>
Prepares the given query as a prepared statement.
Sourcefn close(&mut self, stmt: Statement) -> Result<()>
fn close(&mut self, stmt: Statement) -> Result<()>
This function will close the given statement on the server side.
Sourcefn exec_iter<S, P>(
&mut self,
stmt: S,
params: P,
) -> Result<QueryResult<'_, '_, '_, Binary>>
fn exec_iter<S, P>( &mut self, stmt: S, params: P, ) -> Result<QueryResult<'_, '_, '_, Binary>>
Executes the given stmt with the given params.
Provided Methods§
Sourcefn query<T, Q>(&mut self, query: Q) -> Result<Vec<T>>
fn query<T, Q>(&mut self, query: Q) -> Result<Vec<T>>
Performs text query and collects the first result set.
Sourcefn query_opt<T, Q>(
&mut self,
query: Q,
) -> Result<Vec<StdResult<T, FromRowError>>>
fn query_opt<T, Q>( &mut self, query: Q, ) -> Result<Vec<StdResult<T, FromRowError>>>
Same as Queryable::query but useful when you not sure what your schema is.
Sourcefn query_first<T, Q>(&mut self, query: Q) -> Result<Option<T>>
fn query_first<T, Q>(&mut self, query: Q) -> Result<Option<T>>
Performs text query and returns the first row of the first result set.
Sourcefn query_first_opt<T, Q>(
&mut self,
query: Q,
) -> Result<Option<StdResult<T, FromRowError>>>
fn query_first_opt<T, Q>( &mut self, query: Q, ) -> Result<Option<StdResult<T, FromRowError>>>
Same as Queryable::query_first but useful when you not sure what your schema is.
Sourcefn query_map<T, F, Q, U>(&mut self, query: Q, f: F) -> Result<Vec<U>>
fn query_map<T, F, Q, U>(&mut self, query: Q, f: F) -> Result<Vec<U>>
Performs text query and maps each row of the first result set.
Sourcefn query_map_opt<T, F, Q, U>(&mut self, query: Q, f: F) -> Result<Vec<U>>
fn query_map_opt<T, F, Q, U>(&mut self, query: Q, f: F) -> Result<Vec<U>>
Same as Queryable::query_map but useful when you not sure what your schema is.
Sourcefn query_fold<T, F, Q, U>(&mut self, query: Q, init: U, f: F) -> Result<U>
fn query_fold<T, F, Q, U>(&mut self, query: Q, init: U, f: F) -> Result<U>
Performs text query and folds the first result set to a single value.
Sourcefn query_fold_opt<T, F, Q, U>(&mut self, query: Q, init: U, f: F) -> Result<U>
fn query_fold_opt<T, F, Q, U>(&mut self, query: Q, init: U, f: F) -> Result<U>
Same as Queryable::query_fold but useful when you not sure what your schema is.
Sourcefn query_drop<Q>(&mut self, query: Q) -> Result<()>
fn query_drop<Q>(&mut self, query: Q) -> Result<()>
Performs text query and drops the query result.
Sourcefn exec_batch<S, P, I>(&mut self, stmt: S, params: I) -> Result<()>
fn exec_batch<S, P, I>(&mut self, stmt: S, params: I) -> Result<()>
Prepares the given statement, and executes it with each item in the given params iterator.
Sourcefn exec<T, S, P>(&mut self, stmt: S, params: P) -> Result<Vec<T>>
fn exec<T, S, P>(&mut self, stmt: S, params: P) -> Result<Vec<T>>
Executes the given stmt and collects the first result set.
Sourcefn exec_opt<T, S, P>(
&mut self,
stmt: S,
params: P,
) -> Result<Vec<StdResult<T, FromRowError>>>
fn exec_opt<T, S, P>( &mut self, stmt: S, params: P, ) -> Result<Vec<StdResult<T, FromRowError>>>
Same as Queryable::exec but useful when you not sure what your schema is.
Sourcefn exec_first<T, S, P>(&mut self, stmt: S, params: P) -> Result<Option<T>>
fn exec_first<T, S, P>(&mut self, stmt: S, params: P) -> Result<Option<T>>
Executes the given stmt and returns the first row of the first result set.
Sourcefn exec_first_opt<T, S, P>(
&mut self,
stmt: S,
params: P,
) -> Result<Option<StdResult<T, FromRowError>>>
fn exec_first_opt<T, S, P>( &mut self, stmt: S, params: P, ) -> Result<Option<StdResult<T, FromRowError>>>
Same as Queryable::exec_first but useful when you not sure what your schema is.
Sourcefn exec_map<T, S, P, F, U>(
&mut self,
stmt: S,
params: P,
f: F,
) -> Result<Vec<U>>
fn exec_map<T, S, P, F, U>( &mut self, stmt: S, params: P, f: F, ) -> Result<Vec<U>>
Executes the given stmt and maps each row of the first result set.
Sourcefn exec_map_opt<T, S, P, F, U>(
&mut self,
stmt: S,
params: P,
f: F,
) -> Result<Vec<U>>
fn exec_map_opt<T, S, P, F, U>( &mut self, stmt: S, params: P, f: F, ) -> Result<Vec<U>>
Same as Queryable::exec_map but useful when you not sure what your schema is.
Sourcefn exec_fold<T, S, P, U, F>(
&mut self,
stmt: S,
params: P,
init: U,
f: F,
) -> Result<U>
fn exec_fold<T, S, P, U, F>( &mut self, stmt: S, params: P, init: U, f: F, ) -> Result<U>
Executes the given stmt and folds the first result set to a signel value.
Sourcefn exec_fold_opt<T, S, P, U, F>(
&mut self,
stmt: S,
params: P,
init: U,
f: F,
) -> Result<U>
fn exec_fold_opt<T, S, P, U, F>( &mut self, stmt: S, params: P, init: U, f: F, ) -> Result<U>
Same as Queryable::exec_fold but useful when you not sure what your schema is.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.