pub struct Handle<'c, C: Configuration = DefaultConfiguration> { /* private fields */ }
Expand description
Statically ensures that Connection
can only be used after ResultSet
was consumed to avoid runtime
errors.
Operations on Connection
are only allowed after ResultSet
was dropped.
Allocated PreparedStatement
objects reference Connection
directly so Handle
can be still used to
query or allocate more PreparedStatement
objects.
Implementations§
source§impl<'h, 'c: 'h, C: Configuration> Handle<'c, C>
impl<'h, 'c: 'h, C: Configuration> Handle<'c, C>
pub fn with_configuration<CNew: Configuration>( &mut self, configuration: CNew ) -> Handle<'c, CNew>
sourcepub fn tables<'i, V>(
&'h mut self,
catalog: &'i str,
schema: Option<&'i str>,
table: Option<&'i str>,
table_type: Option<&'i str>
) -> Result<ResultSet<'h, 'c, V, Executed, C>, QueryError>where
V: TryFromRow<C>,
pub fn tables<'i, V>( &'h mut self, catalog: &'i str, schema: Option<&'i str>, table: Option<&'i str>, table_type: Option<&'i str> ) -> Result<ResultSet<'h, 'c, V, Executed, C>, QueryError>where V: TryFromRow<C>,
Query list of tables from given catalog. Optionally result can be filtered by table name and table type.
sourcepub fn prepare(
&'h mut self,
query: &str
) -> Result<PreparedStatement<'c>, OdbcError>
pub fn prepare( &'h mut self, query: &str ) -> Result<PreparedStatement<'c>, OdbcError>
Prepare statement for fast execution and parametrization.
For one-off queries it is more efficient to use query()
function.
sourcepub fn query<V>(
&'h mut self,
query: &str
) -> Result<ResultSet<'h, 'c, V, Executed, C>, QueryError>where
V: TryFromRow<C>,
pub fn query<V>( &'h mut self, query: &str ) -> Result<ResultSet<'h, 'c, V, Executed, C>, QueryError>where V: TryFromRow<C>,
Execute one-off query.
sourcepub fn query_with_parameters<'t, V, F>(
&'h mut self,
query: &str,
bind: F
) -> Result<ResultSet<'h, 'c, V, Executed, C>, QueryError>where
V: TryFromRow<C>,
F: FnOnce(Binder<'c, 'c, Allocated>) -> Result<Binder<'c, 't, Allocated>, BindError>,
pub fn query_with_parameters<'t, V, F>( &'h mut self, query: &str, bind: F ) -> Result<ResultSet<'h, 'c, V, Executed, C>, QueryError>where V: TryFromRow<C>, F: FnOnce(Binder<'c, 'c, Allocated>) -> Result<Binder<'c, 't, Allocated>, BindError>,
Execute one-off query with parameters. This creates prepared statement and binds values to it before execution.
sourcepub fn execute<V>(
&'h mut self,
statement: PreparedStatement<'c>
) -> Result<ResultSet<'h, 'c, V, Prepared, C>, QueryError>where
V: TryFromRow<C>,
pub fn execute<V>( &'h mut self, statement: PreparedStatement<'c> ) -> Result<ResultSet<'h, 'c, V, Prepared, C>, QueryError>where V: TryFromRow<C>,
Execute prepared statement without parameters.
sourcepub fn execute_with_parameters<'t, V, F>(
&'h mut self,
statement: PreparedStatement<'c>,
bind: F
) -> Result<ResultSet<'h, 'c, V, Prepared, C>, QueryError>where
V: TryFromRow<C>,
F: FnOnce(Binder<'c, 'c, Prepared>) -> Result<Binder<'c, 't, Prepared>, BindError>,
pub fn execute_with_parameters<'t, V, F>( &'h mut self, statement: PreparedStatement<'c>, bind: F ) -> Result<ResultSet<'h, 'c, V, Prepared, C>, QueryError>where V: TryFromRow<C>, F: FnOnce(Binder<'c, 'c, Prepared>) -> Result<Binder<'c, 't, Prepared>, BindError>,
Bind parameters and execute prepared statement.
sourcepub fn start_transaction(&mut self) -> Result<(), QueryError>
pub fn start_transaction(&mut self) -> Result<(), QueryError>
Calls “START TRANSACTION”
sourcepub fn commit(&mut self) -> Result<(), QueryError>
pub fn commit(&mut self) -> Result<(), QueryError>
Calls “COMMIT”
sourcepub fn rollback(&mut self) -> Result<(), QueryError>
pub fn rollback(&mut self) -> Result<(), QueryError>
Calls “ROLLBACK”
sourcepub fn in_transaction<O, E>(
&mut self,
f: impl FnOnce(&mut Handle<'c, C>) -> Result<O, E>
) -> Result<Result<O, E>, QueryError>
pub fn in_transaction<O, E>( &mut self, f: impl FnOnce(&mut Handle<'c, C>) -> Result<O, E> ) -> Result<Result<O, E>, QueryError>
Call function in transaction. If function returns Err the transaction will be rolled back otherwise committed.
sourcepub fn outside_of_transaction<O>(
&mut self,
f: impl FnOnce(&mut Handle<'c, C>) -> O
) -> Result<O, QueryError>
pub fn outside_of_transaction<O>( &mut self, f: impl FnOnce(&mut Handle<'c, C>) -> O ) -> Result<O, QueryError>
Commit current transaction, run function and start new transaction. This is useful when you need to do changes with auto-commit (for example change schema) while in open transaction already.