pub struct InitParams { /* private fields */ }
Expand description
Parameters for explicit Oracle client library initialization
Note:
- Any method that invokes C functions in the Oracle client library will implicitly initialize it.
- Regardless of whether it is initialized explicitly or implicitly, it is only once per process.
§Examples
Initialize explicitly twice
// init() returns Ok(true) on the first call.
assert_eq!(InitParams::new().init()?, true);
// It returns Ok(false) when Oracle client library has initialized already.
assert_eq!(InitParams::new().init()?, false);
Initialize implicitly then explicitly
// Oracle client library isn't initialzied at first.
assert_eq!(InitParams::is_initialized(), false);
// It is initialized by any method that invokes C functions in it.
Connection::connect("dummy", "dummy", "");
// Parameters have no effect on the already initialized one.
assert_eq!(
InitParams::new()
.oracle_client_lib_dir("/another/oracle/client/location")?
.init()?,
false
);
Implementations§
Source§impl InitParams
impl InitParams
Sourcepub fn new() -> InitParams
pub fn new() -> InitParams
Creates a new initialization parameter
Sourcepub fn default_driver_name<T>(&mut self, name: T) -> Result<&mut InitParams>
pub fn default_driver_name<T>(&mut self, name: T) -> Result<&mut InitParams>
Sets the default driver name to use when creating pools or standalone connections.
The standard is to set this value to "<name> : <version>"
, where <name>
is the name of the driver and <version>
is its version. There should be a
single space character before and after the colon.
This value is shown in database views that give information about
connections. For example, it is in the CLIENT_DRIVER
column
of V$SESSION_CONNECT_INFO
.
If this member isn’t set, then the default value is "rust-oracle : <version>"
,
where <version>
is the oracle crate version.
This value is propagated to the default value of Connector::driver_name
and PoolBuilder::driver_name
.
§Errors
If name
contains null characters, an error will be returned.
Sourcepub fn load_error_url<T>(&mut self, url: T) -> Result<&mut InitParams>
pub fn load_error_url<T>(&mut self, url: T) -> Result<&mut InitParams>
Sets the URL that should be provided in the error message returned when the Oracle Client library cannot be loaded.
This URL should direct the user to the installation instructions for the application or driver using ODPI-C. If this value isn’t set then the default ODPI-C URL is provided in the error message instead.
§Errors
If url
contains null characters, an error will be returned.
Sourcepub fn oracle_client_lib_dir<T>(&mut self, dir: T) -> Result<&mut InitParams>
pub fn oracle_client_lib_dir<T>(&mut self, dir: T) -> Result<&mut InitParams>
Sets the location from which to load the Oracle Client library.
If this value is set it is the only location that is searched; otherwise, if this value isn’t set the Oracle Client library is searched for in the usual fashion as noted in Oracle Client Library Loading. Also see that section for limitations on using this.
§Errors
If dir
contains null characters, an error will be returned.
On windows, dir
must consist with characters convertible to ANSI code page,
which is, for example, CP1252 in English, CP932 in Japanese.
Otherwise, an error will be returned.
Sourcepub fn oracle_client_config_dir<T>(&mut self, dir: T) -> Result<&mut InitParams>
pub fn oracle_client_config_dir<T>(&mut self, dir: T) -> Result<&mut InitParams>
Sets the location the Oracle client library will search for configuration files.
This is equivalent to setting the environment variable TNS_ADMIN
.
If this value is set, it overrides any value set by the environment
variable TNS_ADMIN
.
§Errors
If dir
contains null characters, an error will be returned.
On windows, dir
must consist with characters convertible to ANSI code page,
which is, for example, CP1252 in English, CP932 in Japanese.
Otherwise, an error will be returned.
Sourcepub fn init(&self) -> Result<bool>
pub fn init(&self) -> Result<bool>
Initializes Oracle client library.
It returns Ok(true)
when Oracle client library hasn’t been initialized
yet and it is initialized successfully.
It returns Ok(false)
when Oracle client library has been initialized
already. Parameter values in self
affect nothing.
Otherwise, it retruns an error.
Sourcepub fn is_initialized() -> bool
pub fn is_initialized() -> bool
Returns true
if Oracle client library has initialized already.
§Examples
// `false` at first
assert_eq!(InitParams::is_initialized(), false);
// Use any method that invokes C functions in the Oracle client library.
Connection::connect("dummy", "dummy", "");
// `true` here
assert_eq!(InitParams::is_initialized(), true);
Trait Implementations§
Source§impl Clone for InitParams
impl Clone for InitParams
Source§fn clone(&self) -> InitParams
fn clone(&self) -> InitParams
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more