Struct mysql::OptsBuilder [−][src]
pub struct OptsBuilder { /* 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"));
Connection URL
Opts
also could be constructed using connection URL. See docs on OptsBuilder
's methods for
the list of options available via URL.
Example:
let connection_url = "mysql://root:password@localhost:3307/mysql?prefer_socket=false"; let pool = my::Pool::new(connection_url).unwrap();
Methods
impl OptsBuilder
[src]
impl OptsBuilder
pub fn new() -> Self
[src]
pub fn new() -> Self
pub fn from_opts<T: Into<Opts>>(opts: T) -> Self
[src]
pub fn from_opts<T: Into<Opts>>(opts: T) -> Self
ⓘImportant traits for &'a mut Rpub fn ip_or_hostname<T: Into<String>>(
&mut self,
ip_or_hostname: Option<T>
) -> &mut Self
[src]
pub 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.
ⓘImportant traits for &'a mut Rpub fn tcp_port(&mut self, tcp_port: u16) -> &mut Self
[src]
pub fn tcp_port(&mut self, tcp_port: u16) -> &mut Self
TCP port of mysql server (defaults to 3306
).
ⓘImportant traits for &'a mut Rpub fn socket<T: Into<String>>(&mut self, socket: Option<T>) -> &mut Self
[src]
pub fn socket<T: Into<String>>(&mut self, socket: Option<T>) -> &mut Self
Socket path on unix or pipe name on windows (defaults to None
).
ⓘImportant traits for &'a mut Rpub fn user<T: Into<String>>(&mut self, user: Option<T>) -> &mut Self
[src]
pub fn user<T: Into<String>>(&mut self, user: Option<T>) -> &mut Self
User (defaults to None
).
ⓘImportant traits for &'a mut Rpub fn pass<T: Into<String>>(&mut self, pass: Option<T>) -> &mut Self
[src]
pub fn pass<T: Into<String>>(&mut self, pass: Option<T>) -> &mut Self
Password (defaults to None
).
ⓘImportant traits for &'a mut Rpub fn db_name<T: Into<String>>(&mut self, db_name: Option<T>) -> &mut Self
[src]
pub fn db_name<T: Into<String>>(&mut self, db_name: Option<T>) -> &mut Self
Database name (defaults to None
).
ⓘImportant traits for &'a mut Rpub fn read_timeout(&mut self, read_timeout: Option<Duration>) -> &mut Self
[src]
pub 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.
ⓘImportant traits for &'a mut Rpub fn write_timeout(&mut self, write_timeout: Option<Duration>) -> &mut Self
[src]
pub 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.
ⓘImportant traits for &'a mut Rpub fn tcp_keepalive_time_ms(
&mut self,
tcp_keepalive_time_ms: Option<u32>
) -> &mut Self
[src]
pub fn tcp_keepalive_time_ms(
&mut self,
tcp_keepalive_time_ms: Option<u32>
) -> &mut Self
TCP keep alive time for mysql connection (defaults to None
). Available as
tcp_keepalive_time_ms
url parameter.
ⓘImportant traits for &'a mut Rpub fn tcp_nodelay(&mut self, nodelay: bool) -> &mut Self
[src]
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.
ⓘImportant traits for &'a mut Rpub fn prefer_socket(&mut self, prefer_socket: bool) -> &mut Self
[src]
pub fn prefer_socket(&mut self, prefer_socket: bool) -> &mut Self
Prefer socket connection (defaults to true
). Available as prefer_socket
url parameter
with value true
or false
.
Will reconnect via socket (on named pipe on windows) after TCP connection
to 127.0.0.1
if true
.
Will fall back to TCP on error. Use socket
option to enforce socket connection.
ⓘImportant traits for &'a mut Rpub fn init<T: Into<String>>(&mut self, init: Vec<T>) -> &mut Self
[src]
pub fn init<T: Into<String>>(&mut self, init: Vec<T>) -> &mut Self
Commands to execute on each new database connection.
ⓘImportant traits for &'a mut Rpub fn verify_peer(&mut self, verify_peer: bool) -> &mut Self
[src]
pub 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
). Available as verify_peer
url
parameter with value true
or false
.
Only make sense if ssl_opts is not None.
ⓘImportant traits for &'a mut Rpub fn ssl_opts<A, B, C>(&mut self, _: Option<Option<()>>) -> &mut Self
[src]
pub fn ssl_opts<A, B, C>(&mut self, _: Option<Option<()>>) -> &mut Self
Requires ssl
feature
ⓘImportant traits for &'a mut Rpub fn local_infile_handler(
&mut self,
handler: Option<LocalInfileHandler>
) -> &mut Self
[src]
pub fn local_infile_handler(
&mut self,
handler: Option<LocalInfileHandler>
) -> &mut Self
Callback to handle requests for local files. These are
caused by using LOAD DATA LOCAL INFILE
queries. The
callback is passed the filename, and a Write
able object
to receive the contents of that file.
If unset, the default callback will read files relative to
the current directory.
ⓘImportant traits for &'a mut Rpub fn tcp_connect_timeout(&mut self, timeout: Option<Duration>) -> &mut Self
[src]
pub fn tcp_connect_timeout(&mut self, timeout: Option<Duration>) -> &mut Self
Tcp connect timeout (defaults to None
). Available as tcp_connect_timeout_ms
url parameter.
ⓘImportant traits for &'a mut Rpub fn bind_address<T>(&mut self, bind_address: Option<T>) -> &mut Self where
T: Into<SocketAddr>,
[src]
pub fn bind_address<T>(&mut self, bind_address: Option<T>) -> &mut Self where
T: Into<SocketAddr>,
Bind address for a client (defaults to None
).
Use carefully. Will probably make pool unusable because of address already in use errors.
ⓘImportant traits for &'a mut Rpub fn stmt_cache_size<T>(&mut self, cache_size: T) -> &mut Self where
T: Into<Option<usize>>,
[src]
pub fn stmt_cache_size<T>(&mut self, cache_size: T) -> &mut Self where
T: Into<Option<usize>>,
Number of prepared statements cached on the client side (per connection). Defaults to 10
.
Available as stmt_cache_size
url parameter.
Call with None
to reset to default.
ⓘImportant traits for &'a mut Rpub fn compress(&mut self, compress: bool) -> &mut Self
[src]
pub fn compress(&mut self, compress: bool) -> &mut Self
If true
, then client will ask for compression if server supports it (defaults to false
).
Available as compress
url parameter with value true
or false
.
ⓘImportant traits for &'a mut Rpub fn additional_capabilities(
&mut self,
additional_capabilities: CapabilityFlags
) -> &mut Self
[src]
pub fn additional_capabilities(
&mut self,
additional_capabilities: CapabilityFlags
) -> &mut Self
Additional client capabilities to set (defaults to empty).
This value will be OR'ed with other client capabilities during connection initialisation.
Note
It is a good way to set something like CLIENT_FOUND_ROWS
but you should note that it
won't let you to interfere with capabilities managed by other options (like
CLIENT_SSL
or CLIENT_COMPRESS
). Also note that some capabilities are reserved,
pointless or may broke the connection, so this option should be used with caution.
Trait Implementations
impl From<OptsBuilder> for Opts
[src]
impl From<OptsBuilder> for Opts
fn from(builder: OptsBuilder) -> Opts
[src]
fn from(builder: OptsBuilder) -> Opts
Performs the conversion.
impl Default for OptsBuilder
[src]
impl Default for OptsBuilder
fn default() -> OptsBuilder
[src]
fn default() -> OptsBuilder
Returns the "default value" for a type. Read more
Auto Trait Implementations
impl Send for OptsBuilder
impl Send for OptsBuilder
impl Sync for OptsBuilder
impl Sync for OptsBuilder