@@ -7,8 +7,8 @@ use super::{
77} ;
88use log:: debug;
99use odbc_sys:: {
10- AttrCpMatch , AttrOdbcVersion , EnvironmentAttribute , FetchOrientation , HDbc , HEnv , Handle ,
11- HandleType , SQLAllocHandle , SQLSetEnvAttr ,
10+ AttrCpMatch , AttrOdbcVersion , EnvironmentAttribute , FetchOrientation , HEnv , Handle , HandleType ,
11+ SQLAllocHandle , SQLSetEnvAttr ,
1212} ;
1313use std:: ptr:: null_mut;
1414
@@ -40,7 +40,7 @@ unsafe impl Send for Environment {}
4040
4141unsafe impl AnyHandle for Environment {
4242 fn as_handle ( & self ) -> Handle {
43- self . handle as Handle
43+ self . handle . as_handle ( )
4444 }
4545
4646 fn handle_type ( & self ) -> HandleType {
@@ -51,7 +51,7 @@ unsafe impl AnyHandle for Environment {
5151impl Drop for Environment {
5252 fn drop ( & mut self ) {
5353 unsafe {
54- drop_handle ( self . handle as Handle , HandleType :: Env ) ;
54+ drop_handle ( self . handle . as_handle ( ) , HandleType :: Env ) ;
5555 }
5656 }
5757}
@@ -72,7 +72,7 @@ impl Environment {
7272 pub unsafe fn set_connection_pooling ( scheme : odbc_sys:: AttrConnectionPooling ) -> SqlResult < ( ) > {
7373 unsafe {
7474 SQLSetEnvAttr (
75- null_mut ( ) ,
75+ HEnv :: null ( ) ,
7676 odbc_sys:: EnvironmentAttribute :: ConnectionPooling ,
7777 scheme. into ( ) ,
7878 odbc_sys:: IS_INTEGER ,
@@ -103,11 +103,12 @@ impl Environment {
103103 // however official sources imply it is ok for an application to have multiple environments
104104 // and I did not get it to race ever on my machine.
105105 unsafe {
106- let mut handle = null_mut ( ) ;
107- let result: SqlResult < ( ) > = SQLAllocHandle ( HandleType :: Env , null_mut ( ) , & mut handle)
108- . into_sql_result ( "SQLAllocHandle" ) ;
106+ let mut handle = Handle :: null ( ) ;
107+ let result: SqlResult < ( ) > =
108+ SQLAllocHandle ( HandleType :: Env , Handle :: null ( ) , & mut handle)
109+ . into_sql_result ( "SQLAllocHandle" ) ;
109110 result. on_success ( || Environment {
110- handle : handle as HEnv ,
111+ handle : handle. as_henv ( ) ,
111112 } )
112113 }
113114 }
@@ -128,12 +129,12 @@ impl Environment {
128129
129130 /// Allocate a new connection handle. The `Connection` must not outlive the `Environment`.
130131 pub fn allocate_connection ( & self ) -> SqlResult < Connection < ' _ > > {
131- let mut handle = null_mut ( ) ;
132+ let mut handle = Handle :: null ( ) ;
132133 unsafe {
133134 SQLAllocHandle ( HandleType :: Dbc , self . as_handle ( ) , & mut handle)
134135 . into_sql_result ( "SQLAllocHandle" )
135136 . on_success ( || {
136- let handle = handle as HDbc ;
137+ let handle = handle. as_hdbc ( ) ;
137138 debug ! ( "SQLAllocHandle allocated connection (Dbc) handle '{handle:?}'" ) ;
138139 Connection :: new ( handle)
139140 } )
0 commit comments