Struct odbc_api::handles::Environment
source · [−]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 stetting of each environment attribute
Implementations
sourceimpl 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]
) -> Option<SqlResult<()>>
pub unsafe fn drivers_buffer_fill(
&self,
direction: FetchOrientation,
buffer_description: &mut [SqlChar],
buffer_attributes: &mut [SqlChar]
) -> Option<SqlResult<()>>
List drivers descriptions and driver attribute keywords. Returns None
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 usecases. 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
) -> Option<SqlResult<(i16, i16)>>
pub unsafe fn drivers_buffer_len(
&self,
direction: FetchOrientation
) -> Option<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 usecases. 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
) -> Option<SqlResult<(i16, i16)>>
pub unsafe fn data_source_buffer_len(
&self,
direction: FetchOrientation
) -> Option<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 usecases. 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]
) -> Option<SqlResult<()>>
pub unsafe fn data_source_buffer_fill(
&self,
direction: FetchOrientation,
buffer_name: &mut [SqlChar],
buffer_description: &mut [SqlChar]
) -> Option<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 usecases. 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
).buffer_name
: In casetrue
is returned this buffer is filled with the name of the datasource.buffer_description
: In casetrue
is returned this buffer is filled with a description of the datasource (i.e. Driver name).
Use Environment::data_source_buffer_len
to determine buffer lengths.
Trait Implementations
sourceimpl AsHandle for Environment
impl AsHandle for Environment
sourcefn as_handle(&self) -> Handle
fn as_handle(&self) -> Handle
The raw underlying ODBC handle used to talk to the ODBC C API. The handle must be valid.
sourcefn handle_type(&self) -> HandleType
fn handle_type(&self) -> HandleType
The type of the ODBC handle returned by as_handle
. This is a method rather than a constant
in order to make the type object safe. Read more
sourceimpl Debug for Environment
impl Debug for Environment
sourceimpl Drop for Environment
impl Drop for Environment
impl Send for Environment
Auto Trait Implementations
impl RefUnwindSafe for Environment
impl !Sync for Environment
impl Unpin for Environment
impl UnwindSafe for Environment
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more