Skip to main content

build_opts

Function build_opts 

Source
pub fn build_opts(conn: &str) -> Result<OptsBuilder, MySQLSourceError>
Expand description

Build the connection options for a MySQL URL, translating the ssl-mode (and ssl-ca) query parameters into a [SslOpts].

The mysql crate configures TLS programmatically via [OptsBuilder::ssl_opts] and errors on unknown URL parameters, so the SSL parameters are parsed and removed here rather than passed through to [Opts::from_url].

The crate also defaults prefer_socket to true. After a TCP handshake to a loopback address it reads the server’s socket variable and reconnects through that Unix socket, so a forwarded port such as 127.0.0.1:9999 lands on the local server. An explicit TCP port disables that automatic preference. A URL that sets socket or prefer_socket, and a URL with no port, keeps the parsed driver value.