Struct odbc_iter::Handle

source ·
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>

source

pub fn with_configuration<CNew: Configuration>( &mut self, configuration: CNew ) -> Handle<'c, CNew>

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

pub fn start_transaction(&mut self) -> Result<(), QueryError>

Calls “START TRANSACTION”

source

pub fn commit(&mut self) -> Result<(), QueryError>

Calls “COMMIT”

source

pub fn rollback(&mut self) -> Result<(), QueryError>

Calls “ROLLBACK”

source

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.

source

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.

Trait Implementations§

source§

impl<'c, C: Debug + Configuration> Debug for Handle<'c, C>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'c, C> RefUnwindSafe for Handle<'c, C>where C: RefUnwindSafe,

§

impl<'c, C = DefaultConfiguration> !Send for Handle<'c, C>

§

impl<'c, C = DefaultConfiguration> !Sync for Handle<'c, C>

§

impl<'c, C> Unpin for Handle<'c, C>where C: Unpin,

§

impl<'c, C> UnwindSafe for Handle<'c, C>where C: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToErrorNoContext<T> for T

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<E, C> WrapContext<C> for E

§

type ContextError = ErrorContext<E, C>

source§

fn wrap_context(self, context: C) -> ErrorContext<E, C>