odbc_api/handles/
any_handle.rs

1use odbc_sys::{Handle, HandleType};
2
3/// Provides access to the raw underlying ODBC handle. This trait is implemented for environment,
4/// connection and statement handles. [`Self::handle_type`] allows to determine the type of the
5/// handle at runtime. Yet, this information is not in the type system. This is useful for
6/// operations, which must work with all handle types. E.g. fetching diagnostics.
7///
8/// # Safety
9///
10/// The handle provided by `as_handle` must be valid and match the type returned by `handle_type`.
11pub unsafe trait AnyHandle {
12    /// The raw underlying ODBC handle used to talk to the ODBC C API. The handle must be valid.
13    fn as_handle(&self) -> Handle;
14
15    /// The type of the ODBC handle returned by `as_handle`. This is a method rather than a constant
16    /// in order to make the type object safe.
17    fn handle_type(&self) -> HandleType;
18}