pub struct MySqlConfig {Show 13 fields
pub host: String,
pub port: u16,
pub user: String,
pub password: Option<String>,
pub database: Option<String>,
pub charset: u8,
pub connect_timeout: Duration,
pub ssl_mode: SslMode,
pub tls_config: TlsConfig,
pub compression: bool,
pub attributes: HashMap<String, String>,
pub local_infile: bool,
pub max_packet_size: u32,
}Expand description
MySQL connection configuration.
Fields§
§host: StringHostname or IP address
port: u16Port number (default: 3306)
user: StringUsername for authentication
password: Option<String>Password for authentication
database: Option<String>Database name to connect to (optional at connect time)
charset: u8Character set (default: utf8mb4)
connect_timeout: DurationConnection timeout
ssl_mode: SslModeSSL mode
tls_config: TlsConfigTLS configuration (certificates, keys, etc.)
compression: boolEnable compression (CLIENT_COMPRESS capability)
attributes: HashMap<String, String>Additional connection attributes
local_infile: boolLocal infile handling (disabled by default for security)
max_packet_size: u32Max allowed packet size (default: 64MB)
Implementations§
Source§impl MySqlConfig
impl MySqlConfig
Sourcepub fn connect_timeout(self, timeout: Duration) -> Self
pub fn connect_timeout(self, timeout: Duration) -> Self
Set the connection timeout.
Sourcepub fn tls_config(self, config: TlsConfig) -> Self
pub fn tls_config(self, config: TlsConfig) -> Self
Set the TLS configuration.
Sourcepub fn ca_cert(self, path: impl Into<PathBuf>) -> Self
pub fn ca_cert(self, path: impl Into<PathBuf>) -> Self
Set the CA certificate path for TLS.
This is a convenience method equivalent to:
config.tls_config(TlsConfig::new().ca_cert(path))Sourcepub fn client_cert(
self,
cert_path: impl Into<PathBuf>,
key_path: impl Into<PathBuf>,
) -> Self
pub fn client_cert( self, cert_path: impl Into<PathBuf>, key_path: impl Into<PathBuf>, ) -> Self
Set client certificate and key paths for mutual TLS.
Both cert and key must be provided for client authentication.
Sourcepub fn compression(self, enabled: bool) -> Self
pub fn compression(self, enabled: bool) -> Self
Enable or disable compression.
Sourcepub fn attribute(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn attribute(self, key: impl Into<String>, value: impl Into<String>) -> Self
Set a connection attribute.
Sourcepub fn local_infile(self, enabled: bool) -> Self
pub fn local_infile(self, enabled: bool) -> Self
Enable or disable local infile handling.
§Security Warning
Enabling local infile can be a security risk. Only enable if you trust the server and understand the implications.
Sourcepub fn max_packet_size(self, size: u32) -> Self
pub fn max_packet_size(self, size: u32) -> Self
Set the max allowed packet size.
Sourcepub fn socket_addr(&self) -> String
pub fn socket_addr(&self) -> String
Get the socket address string for connection.
Sourcepub fn capability_flags(&self) -> u32
pub fn capability_flags(&self) -> u32
Build capability flags based on configuration.
Trait Implementations§
Source§impl Clone for MySqlConfig
impl Clone for MySqlConfig
Source§fn clone(&self) -> MySqlConfig
fn clone(&self) -> MySqlConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more