Config

Struct Config 

Source
pub struct Config {
    pub host: String,
    pub port: u16,
    pub service: ServiceMethod,
    pub username: String,
    pub tls_mode: TlsMode,
    pub tls_config: Option<TlsConfig>,
    pub connect_timeout: Duration,
    pub sdu: u32,
    pub charset_id: u16,
    pub ncharset_id: u16,
    pub stmtcachesize: usize,
    /* private fields */
}
Expand description

Connection configuration for Oracle databases.

This struct holds all the parameters needed to establish a connection to an Oracle database, including host, port, credentials, TLS settings, and more.

§Examples

§Basic connection

use oracle_rs::Config;

let config = Config::new("localhost", 1521, "FREEPDB1", "user", "password");

§TLS connection with system certificates

use oracle_rs::Config;

let config = Config::new("hostname", 2484, "service", "user", "password")
    .with_tls()
    .expect("TLS configuration failed");

§TLS connection with Oracle wallet

use oracle_rs::Config;

let config = Config::new("hostname", 2484, "service", "user", "password")
    .with_wallet("/path/to/wallet", Some("wallet_password"))
    .expect("Wallet configuration failed");

§With custom options

use oracle_rs::Config;
use std::time::Duration;

let config = Config::new("localhost", 1521, "FREEPDB1", "user", "password")
    .connect_timeout(Duration::from_secs(30))
    .stmtcachesize(50);

Fields§

§host: String

Host to connect to

§port: u16

Port to connect to

§service: ServiceMethod

Service name or SID

§username: String

Username for authentication

§tls_mode: TlsMode

TLS mode

§tls_config: Option<TlsConfig>

TLS configuration (certificates, wallet, etc.)

§connect_timeout: Duration

Connection timeout

§sdu: u32

SDU (Session Data Unit) size

§charset_id: u16

Client charset ID

§ncharset_id: u16

National charset ID

§stmtcachesize: usize

Statement cache size (0 = disabled)

Implementations§

Source§

impl Config

Source

pub fn new( host: impl Into<String>, port: u16, service_name: impl Into<String>, username: impl Into<String>, password: impl Into<String>, ) -> Self

Create a new configuration with service name

Source

pub fn with_sid( host: impl Into<String>, port: u16, sid: impl Into<String>, username: impl Into<String>, password: impl Into<String>, ) -> Self

Create a new configuration with SID

Source

pub fn tls(self, mode: TlsMode) -> Self

Set TLS mode

Source

pub fn tls_config(self, config: TlsConfig) -> Self

Set TLS configuration

Source

pub fn is_tls_enabled(&self) -> bool

Check if TLS is enabled

Source

pub fn with_tls(self) -> Result<Self>

Enable TLS with system root certificates.

This configures the connection to use TLS (TCPS protocol) with the system’s trusted root certificate store for server verification.

§Example
use oracle_rs::Config;

let config = Config::new("hostname", 2484, "service", "user", "password")
    .with_tls()
    .expect("TLS configuration failed");
Source

pub fn with_wallet( self, wallet_path: impl Into<String>, wallet_password: Option<&str>, ) -> Result<Self>

Enable TLS with an Oracle wallet.

Oracle wallets (ewallet.p12 or ewallet.pem files) contain certificates and keys for secure connections. This is the standard way to configure TLS for Oracle Cloud and enterprise deployments.

§Arguments
  • wallet_path - Path to the wallet directory containing ewallet.pem
  • wallet_password - Optional password for encrypted wallets
§Example
use oracle_rs::Config;

let config = Config::new("hostname", 2484, "service", "user", "password")
    .with_wallet("/path/to/wallet", Some("wallet_password"))
    .expect("Wallet configuration failed");
Source

pub fn with_drcp(self, _connection_class: &str, _purity: &str) -> Self

Configure DRCP (Database Resident Connection Pooling).

DRCP allows the database server to maintain a pool of connections that can be shared across multiple client processes, reducing server resource usage.

§Arguments
  • connection_class - Name identifying this class of connections
  • purity - Either “self” (dedicated) or “new” (can share with others)
§Example
use oracle_rs::Config;

let config = Config::new("hostname", 1521, "service", "user", "password")
    .with_drcp("my_app", "self");
Source

pub fn with_statement_cache_size(self, size: usize) -> Self

Set the statement cache size.

Statement caching improves performance by reusing parsed SQL statements. Set to 0 to disable caching.

Default is 20 (matches python-oracledb default).

§Example
use oracle_rs::Config;

let config = Config::new("localhost", 1521, "FREEPDB1", "user", "password")
    .with_statement_cache_size(100);
Source

pub fn connect_timeout(self, timeout: Duration) -> Self

Set connection timeout

Source

pub fn sdu(self, sdu: u32) -> Self

Set SDU size

Source

pub fn stmtcachesize(self, size: usize) -> Self

Set statement cache size

Set to 0 to disable statement caching. Default is 20 (matches python-oracledb default).

Source

pub fn set_password(&mut self, password: impl Into<String>)

Set the password

Source

pub fn set_username(&mut self, username: impl Into<String>)

Set the username

Source

pub fn build_connect_string(&self) -> String

Build a TNS connect descriptor string

Source

pub fn socket_addr(&self) -> String

Get the socket address string

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a duplicate of the value. Read more
1.0.0§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

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

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

impl Default for Config

Source§

fn default() -> Self

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

impl Display for Config

Source§

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

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

impl FromStr for Config

Parse an EZConnect-style connection string

Formats supported:

  • host:port/service_name
  • host/service_name
  • host:port:sid
  • //host:port/service_name (with optional leading slashes)
Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self>

Parses a string s to return a value of this type. Read more

Auto Trait Implementations§

§

impl Freeze for Config

§

impl RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnwindSafe for Config

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

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
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
§

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

§

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> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

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

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

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T> ToString for T
where T: Display + ?Sized,

§

fn to_string(&self) -> String

Converts the given value to a String. Read more
§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more