Struct InitParams

Source
pub struct InitParams { /* private fields */ }
Expand description

Parameters for explicit Oracle client library initialization

Note:

  1. Any method that invokes C functions in the Oracle client library will implicitly initialize it.
  2. 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

Source

pub fn new() -> InitParams

Creates a new initialization parameter

Source

pub fn default_driver_name<T>(&mut self, name: T) -> Result<&mut InitParams>
where T: Into<String>,

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.

Source

pub fn load_error_url<T>(&mut self, url: T) -> Result<&mut InitParams>
where T: Into<String>,

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.

Source

pub fn oracle_client_lib_dir<T>(&mut self, dir: T) -> Result<&mut InitParams>
where T: Into<OsString>,

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.

Source

pub fn oracle_client_config_dir<T>(&mut self, dir: T) -> Result<&mut InitParams>
where T: Into<OsString>,

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.

Source

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.

Source

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

Source§

fn clone(&self) -> InitParams

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for InitParams

Source§

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

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

impl Default for InitParams

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.