Struct mysql::OptsBuilder
[−]
[src]
pub struct OptsBuilder { // some fields omitted }
Provides a way to build Opts
.
// You can create new default builder let mut builder = OptsBuilder::new(); builder.ip_or_hostname(Some("foo")) .db_name(Some("bar")) .ssl_opts(Some(("/foo/cert.pem", None::<(String, String)>))); // Or use existing T: Into<Opts> let mut builder = OptsBuilder::from_opts(existing_opts); builder.ip_or_hostname(Some("foo")) .db_name(Some("bar"));
Methods
impl OptsBuilder
[src]
fn new() -> Self
fn from_opts<T: Into<Opts>>(opts: T) -> Self
fn ip_or_hostname<T: Into<String>>(&mut self, ip_or_hostname: Option<T>) -> &mut Self
Address of mysql server (defaults to 127.0.0.1
). Hostnames should also work.
fn tcp_port(&mut self, tcp_port: u16) -> &mut Self
TCP port of mysql server (defaults to 3306
).
fn unix_addr<T: Into<PathBuf>>(&mut self, unix_addr: Option<T>) -> &mut Self
Path to unix socket of mysql server (defaults to None
).
fn user<T: Into<String>>(&mut self, user: Option<T>) -> &mut Self
User (defaults to None
).
fn pass<T: Into<String>>(&mut self, pass: Option<T>) -> &mut Self
Password (defaults to None
).
fn db_name<T: Into<String>>(&mut self, db_name: Option<T>) -> &mut Self
Database name (defaults to None
).
fn read_timeout(&mut self, read_timeout: Option<Duration>) -> &mut Self
The timeout for each attempt to read from the server (defaults to None
).
Note that named pipe connection will ignore duration's nanos
, and also note that
it is an error to pass the zero Duration
to this method.
fn write_timeout(&mut self, write_timeout: Option<Duration>) -> &mut Self
The timeout for each attempt to write to the server (defaults to None
).
Note that named pipe connection will ignore duration's nanos
, and also note that
it is likely error to pass the zero Duration
to this method.
fn prefer_socket(&mut self, prefer_socket: bool) -> &mut Self
Prefer socket connection (defaults to true
).
Will reconnect via socket after TCP connection to 127.0.0.1
if true
.
fn init<T: Into<String>>(&mut self, init: Vec<T>) -> &mut Self
Commands to execute on each new database connection.
fn verify_peer(&mut self, verify_peer: bool) -> &mut Self
Only available if ssl
feature enabled.
Perform or not ssl peer verification (defaults to false
).
Only make sense if ssl_opts is not None.
fn ssl_opts<A, B, C>(&mut self, ssl_opts: Option<(A, Option<(B, C)>)>) -> &mut Self where A: Into<PathBuf>, B: Into<PathBuf>, C: Into<PathBuf>
Only available if ssl
feature enabled.
SSL certificates and keys in pem format. If not None, then ssl connection implied.
Option<(ca_cert, Option<(client_cert, client_key)>)>.
Trait Implementations
impl Default for OptsBuilder
[src]
fn default() -> OptsBuilder
Returns the "default value" for a type. Read more