odbc_api::handles

Struct 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 setting of each environment attribute

Implementations§

Source§

impl Environment

Source

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.

Source

pub fn set_connection_pooling_matching( &mut self, matching: AttrCpMatch, ) -> SqlResult<()>

Source

pub fn new() -> SqlResult<Self>

An allocated ODBC Environment handle

Source

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.

Source

pub fn allocate_connection(&self) -> SqlResult<Connection<'_>>

Allocate a new connection handle. The Connection must not outlive the Environment.

Source

pub fn as_raw(&self) -> HEnv

Provides access to the raw ODBC environment handle.

Source

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 case true is returned this buffer is filled with the description of the driver.
  • buffer_attributes: In case true 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

Source

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
§Return

(driver description length, attribute length). Length is in characters minus terminating terminating zero.

See SQLDrivers

Source

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
§Return

(server name length, description length). Length is in characters minus terminating zero.

Source

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

Use Environment::data_source_buffer_len to determine buffer lengths.

Trait Implementations§

Source§

impl AsHandle for Environment

Source§

fn as_handle(&self) -> Handle

The raw underlying ODBC handle used to talk to the ODBC C API. The handle must be valid.
Source§

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.
Source§

impl Debug for Environment

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Drop for Environment

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Environment

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> Diagnostics for T
where T: AsHandle + ?Sized,

Source§

fn diagnostic_record( &self, rec_number: i16, message_text: &mut [u8], ) -> Option<DiagnosticResult>

Call this method to retrieve diagnostic information for the last call to an ODBC function. Read more
Source§

fn diagnostic_record_vec( &self, rec_number: i16, message_text: &mut Vec<SqlChar>, ) -> Option<DiagnosticResult>

Call this method to retrieve diagnostic information for the last call to an ODBC function. This method builds on top of Self::diagnostic_record, if the message does not fit in the buffer, it will grow the message buffer and extract it again. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.