Struct mysql_async::OptsBuilder
source · pub struct OptsBuilder { /* private fields */ }
Expand description
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"));
Implementations§
source§impl OptsBuilder
impl OptsBuilder
pub fn new() -> Self
pub fn from_opts<T: Into<Opts>>(opts: T) -> Self
sourcepub fn ip_or_hostname<T: Into<String>>(&mut self, ip_or_hostname: T) -> &mut Self
pub fn ip_or_hostname<T: Into<String>>(&mut self, ip_or_hostname: T) -> &mut Self
Address of mysql server (defaults to 127.0.0.1
). Hostnames should also work.
sourcepub fn tcp_port(&mut self, tcp_port: u16) -> &mut Self
pub fn tcp_port(&mut self, tcp_port: u16) -> &mut Self
TCP port of mysql server (defaults to 3306
).
sourcepub fn pass<T: Into<String>>(&mut self, pass: Option<T>) -> &mut Self
pub fn pass<T: Into<String>>(&mut self, pass: Option<T>) -> &mut Self
Password (defaults to None
).
sourcepub fn db_name<T: Into<String>>(&mut self, db_name: Option<T>) -> &mut Self
pub fn db_name<T: Into<String>>(&mut self, db_name: Option<T>) -> &mut Self
Database name (defaults to None
).
sourcepub fn init<T: Into<String>>(&mut self, init: Vec<T>) -> &mut Self
pub fn init<T: Into<String>>(&mut self, init: Vec<T>) -> &mut Self
Commands to execute on each new database connection.
sourcepub fn tcp_keepalive<T: Into<u32>>(
&mut self,
tcp_keepalive: Option<T>
) -> &mut Self
pub fn tcp_keepalive<T: Into<u32>>(
&mut self,
tcp_keepalive: Option<T>
) -> &mut Self
TCP keep alive timeout in milliseconds (defaults to None
).
sourcepub fn tcp_nodelay(&mut self, nodelay: bool) -> &mut Self
pub fn tcp_nodelay(&mut self, nodelay: bool) -> &mut Self
Set the TCP_NODELAY
option for the mysql connection (defaults to true
).
Setting this option to false re-enables Nagle’s algorithm, which can cause unusually high latency (~40ms) but may increase maximum throughput. See #132.
sourcepub fn local_infile_handler<T>(&mut self, handler: Option<T>) -> &mut Selfwhere
T: LocalInfileHandler + 'static,
pub fn local_infile_handler<T>(&mut self, handler: Option<T>) -> &mut Selfwhere
T: LocalInfileHandler + 'static,
Handler for local infile requests (defaults to None
).
sourcepub fn pool_min<T: Into<usize>>(&mut self, pool_min: Option<T>) -> &mut Self
pub fn pool_min<T: Into<usize>>(&mut self, pool_min: Option<T>) -> &mut Self
Lower bound of opened connections for Pool
(defaults to 10
. None
to reset to default).
sourcepub fn pool_max<T: Into<usize>>(&mut self, pool_max: Option<T>) -> &mut Self
pub fn pool_max<T: Into<usize>>(&mut self, pool_max: Option<T>) -> &mut Self
Lower bound of opened connections for Pool
(defaults to 100
. None
to reset to default).
sourcepub fn conn_ttl<T: Into<u32>>(&mut self, conn_ttl: Option<T>) -> &mut Self
pub fn conn_ttl<T: Into<u32>>(&mut self, conn_ttl: Option<T>) -> &mut Self
Pool will close connection if time since last IO exceeds this value
(defaults to wait_timeout
. None
to reset to default).
Trait Implementations§
source§impl Clone for OptsBuilder
impl Clone for OptsBuilder
source§fn clone(&self) -> OptsBuilder
fn clone(&self) -> OptsBuilder
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more