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: StringHost to connect to
port: u16Port to connect to
service: ServiceMethodService name or SID
username: StringUsername for authentication
tls_mode: TlsModeTLS mode
tls_config: Option<TlsConfig>TLS configuration (certificates, wallet, etc.)
connect_timeout: DurationConnection timeout
sdu: u32SDU (Session Data Unit) size
charset_id: u16Client charset ID
ncharset_id: u16National charset ID
stmtcachesize: usizeStatement cache size (0 = disabled)
Implementations§
Source§impl Config
impl Config
Sourcepub fn new(
host: impl Into<String>,
port: u16,
service_name: impl Into<String>,
username: impl Into<String>,
password: impl Into<String>,
) -> Self
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
Sourcepub fn with_sid(
host: impl Into<String>,
port: u16,
sid: impl Into<String>,
username: impl Into<String>,
password: impl Into<String>,
) -> Self
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
Sourcepub fn tls_config(self, config: TlsConfig) -> Self
pub fn tls_config(self, config: TlsConfig) -> Self
Set TLS configuration
Sourcepub fn is_tls_enabled(&self) -> bool
pub fn is_tls_enabled(&self) -> bool
Check if TLS is enabled
Sourcepub fn with_tls(self) -> Result<Self>
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");Sourcepub fn with_wallet(
self,
wallet_path: impl Into<String>,
wallet_password: Option<&str>,
) -> Result<Self>
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.pemwallet_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");Sourcepub fn with_drcp(self, _connection_class: &str, _purity: &str) -> Self
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 connectionspurity- 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");Sourcepub fn with_statement_cache_size(self, size: usize) -> Self
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);Sourcepub fn connect_timeout(self, timeout: Duration) -> Self
pub fn connect_timeout(self, timeout: Duration) -> Self
Set connection timeout
Sourcepub fn stmtcachesize(self, size: usize) -> Self
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).
Sourcepub fn set_password(&mut self, password: impl Into<String>)
pub fn set_password(&mut self, password: impl Into<String>)
Set the password
Sourcepub fn set_username(&mut self, username: impl Into<String>)
pub fn set_username(&mut self, username: impl Into<String>)
Set the username
Sourcepub fn build_connect_string(&self) -> String
pub fn build_connect_string(&self) -> String
Build a TNS connect descriptor string
Sourcepub fn socket_addr(&self) -> String
pub fn socket_addr(&self) -> String
Get the socket address string
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)