pub struct Environment { /* private fields */ }
Expand description
An Environment
is a global context, in which to access data.
Associated with an Environment
is any information that is global in nature, such as:
- The
Environment
’s state - The current environment-level diagnostics
- The handles of connections currently allocated on the environment
- The current setting of each environment attribute
Implementations§
Source§impl Environment
impl Environment
Sourcepub unsafe fn set_connection_pooling(
scheme: AttrConnectionPooling,
) -> SqlResult<()>
pub unsafe fn set_connection_pooling( scheme: AttrConnectionPooling, ) -> SqlResult<()>
Enable or disable (default) connection pooling for ODBC connections. Call this function before creating the ODBC environment for which you want to enable connection pooling.
See: https://docs.microsoft.com/en-us/sql/odbc/reference/develop-app/driver-manager-connection-pooling
§Safety
An ODBC driver must be fully thread-safe, and connections must not have thread affinity to support connection pooling. This means the driver is able to handle a call on any thread at any time and is able to connect on one thread, to use the connection on another thread, and to disconnect on a third thread.
pub fn set_connection_pooling_matching( &mut self, matching: AttrCpMatch, ) -> SqlResult<()>
Sourcepub fn declare_version(&self, version: AttrOdbcVersion) -> SqlResult<()>
pub fn declare_version(&self, version: AttrOdbcVersion) -> SqlResult<()>
Declares which Version of the ODBC API we want to use. This is the first thing that should be done with any ODBC environment.
Sourcepub fn allocate_connection(&self) -> SqlResult<Connection<'_>>
pub fn allocate_connection(&self) -> SqlResult<Connection<'_>>
Allocate a new connection handle. The Connection
must not outlive the Environment
.
Sourcepub unsafe fn drivers_buffer_fill(
&self,
direction: FetchOrientation,
buffer_description: &mut [SqlChar],
buffer_attributes: &mut [SqlChar],
) -> SqlResult<()>
pub unsafe fn drivers_buffer_fill( &self, direction: FetchOrientation, buffer_description: &mut [SqlChar], buffer_attributes: &mut [SqlChar], ) -> SqlResult<()>
List drivers descriptions and driver attribute keywords. Returns NoData
to indicate the
end of the list.
§Safety
Callers need to make sure only one thread is iterating over driver information at a time.
Method changes environment state. This method would be safe to call via an exclusive &mut
reference, yet that would restrict use cases. E.g. requesting information would only be
possible before connections borrow a reference.
§Parameters
direction
: Determines whether the Driver Manager fetches the next driver in the list (FetchOrientation::Next
) or whether the search starts from the beginning of the list (FetchOrientation::First
).buffer_description
: In casetrue
is returned this buffer is filled with the description of the driver.buffer_attributes
: In casetrue
is returned this buffer is filled with a list of key value attributes. E.g.:"key1=value1\0key2=value2\0\0"
.
Use Environment::drivers_buffer_len
to determine buffer lengths.
See SQLDrivers
Sourcepub unsafe fn drivers_buffer_len(
&self,
direction: FetchOrientation,
) -> SqlResult<(i16, i16)>
pub unsafe fn drivers_buffer_len( &self, direction: FetchOrientation, ) -> SqlResult<(i16, i16)>
Use together with Environment::drivers_buffer_fill
to list drivers descriptions and
driver attribute keywords.
§Safety
Callers need to make sure only one thread is iterating over driver information at a time.
Method changes environment state. This method would be safe to call via an exclusive &mut
reference, yet that would restrict use cases. E.g. requesting information would only be
possible before connections borrow a reference.
§Parameters
direction
: Determines whether the Driver Manager fetches the next driver in the list (FetchOrientation::Next
) or whether the search starts from the beginning of the list (FetchOrientation::First
).
§Return
(driver description length, attribute length)
. Length is in characters minus terminating
terminating zero.
See SQLDrivers
Sourcepub unsafe fn data_source_buffer_len(
&self,
direction: FetchOrientation,
) -> SqlResult<(i16, i16)>
pub unsafe fn data_source_buffer_len( &self, direction: FetchOrientation, ) -> SqlResult<(i16, i16)>
Use together with Environment::data_source_buffer_fill
to list drivers descriptions and
driver attribute keywords.
§Safety
Callers need to make sure only one thread is iterating over data source information at a
time. Method changes environment state. This method would be safe to call via an exclusive
&mut
reference, yet that would restrict use cases. E.g. requesting information would only
be possible before connections borrow a reference.
§Parameters
direction
: Determines whether the Driver Manager fetches the next driver in the list (FetchOrientation::Next
) or whether the search starts from the beginning of the list (FetchOrientation::First
,FetchOrientation::FirstSystem
,FetchOrientation::FirstUser
).
§Return
(server name length, description length)
. Length is in characters minus terminating zero.
Sourcepub unsafe fn data_source_buffer_fill(
&self,
direction: FetchOrientation,
buffer_name: &mut [SqlChar],
buffer_description: &mut [SqlChar],
) -> SqlResult<()>
pub unsafe fn data_source_buffer_fill( &self, direction: FetchOrientation, buffer_name: &mut [SqlChar], buffer_description: &mut [SqlChar], ) -> SqlResult<()>
List drivers descriptions and driver attribute keywords.
§Safety
Callers need to make sure only one thread is iterating over data source information at a
time. Method changes environment state. This method would be safe to call via an exclusive
&mut
reference, yet that would restrict use cases. E.g. requesting information would only
be possible before connections borrow a reference. SqlResult::NoData
§Parameters
direction
: Determines whether the Driver Manager fetches the next driver in the list (FetchOrientation::Next
) or whether the search starts from the beginning of the list (FetchOrientation::First
,FetchOrientation::FirstSystem
,FetchOrientation::FirstUser
).buffer_name
: 0illed with the name of the datasource if availablebuffer_description
: Filled with a description of the datasource (i.e. Driver name).
Use Environment::data_source_buffer_len
to determine buffer lengths.
Trait Implementations§
Source§impl AsHandle for Environment
impl AsHandle for Environment
Source§fn as_handle(&self) -> Handle
fn as_handle(&self) -> Handle
Source§fn handle_type(&self) -> HandleType
fn handle_type(&self) -> HandleType
as_handle
. This is a method rather than a constant
in order to make the type object safe.Source§impl Debug for Environment
impl Debug for Environment
Source§impl Drop for Environment
impl Drop for Environment
impl Send for Environment
Auto Trait Implementations§
impl Freeze for Environment
impl RefUnwindSafe for Environment
impl !Sync for Environment
impl Unpin for Environment
impl UnwindSafe for Environment
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Diagnostics for T
impl<T> Diagnostics for T
Source§fn diagnostic_record(
&self,
rec_number: i16,
message_text: &mut [u8],
) -> Option<DiagnosticResult>
fn diagnostic_record( &self, rec_number: i16, message_text: &mut [u8], ) -> Option<DiagnosticResult>
Source§fn diagnostic_record_vec(
&self,
rec_number: i16,
message_text: &mut Vec<SqlChar>,
) -> Option<DiagnosticResult>
fn diagnostic_record_vec( &self, rec_number: i16, message_text: &mut Vec<SqlChar>, ) -> Option<DiagnosticResult>
Self::diagnostic_record
, if the message does not fit in the
buffer, it will grow the message buffer and extract it again. Read more