[−][src]Struct mysql::OptsBuilder
Provides a way to build Opts
.
let mut ssl_opts = SslOpts::new(); ssl_opts.set_pkcs12_path("/foo/cert.p12") .set_root_ca_path("/foo/root_ca.der"); // You can create new default builder let mut builder = OptsBuilder::new(); builder.ip_or_hostname(Some("foo")) .db_name(Some("bar")) .ssl_opts(Some(ssl_opts)); // 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]
pub fn new() -> Self
[src]
pub fn from_opts<T: Into<Opts>>(opts: T) -> Self
[src]
pub fn ip_or_hostname<T: Into<String>>(self, ip_or_hostname: Option<T>) -> Self
[src]
Address of mysql server (defaults to 127.0.0.1
). Hostnames should also work.
Note: IPv6 addresses must be given in square brackets, e.g. [::1]
.
pub fn tcp_port(self, tcp_port: u16) -> Self
[src]
TCP port of mysql server (defaults to 3306
).
pub fn socket<T: Into<String>>(self, socket: Option<T>) -> Self
[src]
Socket path on unix or pipe name on windows (defaults to None
).
Can be defined using socket
connection url parameter.
pub fn user<T: Into<String>>(self, user: Option<T>) -> Self
[src]
User (defaults to None
).
pub fn pass<T: Into<String>>(self, pass: Option<T>) -> Self
[src]
Password (defaults to None
).
pub fn db_name<T: Into<String>>(self, db_name: Option<T>) -> Self
[src]
Database name (defaults to None
).
pub fn read_timeout(self, read_timeout: Option<Duration>) -> Self
[src]
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.
pub fn write_timeout(self, write_timeout: Option<Duration>) -> Self
[src]
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.
pub fn tcp_keepalive_time_ms(self, tcp_keepalive_time_ms: Option<u32>) -> Self
[src]
TCP keep alive time for mysql connection (defaults to None
). Available as
tcp_keepalive_time_ms
url parameter.
Can be defined using tcp_keepalive_time_ms
connection url parameter.
pub fn tcp_nodelay(self, nodelay: bool) -> Self
[src]
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.
pub fn prefer_socket(self, prefer_socket: bool) -> Self
[src]
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.
Can be defined using prefer_socket
connection url parameter.
pub fn init<T: Into<String>>(self, init: Vec<T>) -> Self
[src]
Commands to execute on each new database connection.
pub fn ssl_opts<T: Into<Option<SslOpts>>>(self, ssl_opts: T) -> Self
[src]
Driver will require SSL connection if this option isn't None
(default to None
).
pub fn local_infile_handler(self, handler: Option<LocalInfileHandler>) -> Self
[src]
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.
pub fn tcp_connect_timeout(self, timeout: Option<Duration>) -> Self
[src]
Tcp connect timeout (defaults to None
). Available as tcp_connect_timeout_ms
url parameter.
Can be defined using tcp_connect_timeout_ms
connection url parameter.
pub fn bind_address<T>(self, bind_address: Option<T>) -> Self where
T: Into<SocketAddr>,
[src]
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.
pub fn stmt_cache_size<T>(self, cache_size: T) -> Self where
T: Into<Option<usize>>,
[src]
T: Into<Option<usize>>,
Number of prepared statements cached on the client side (per connection).
Defaults to DEFAULT_STMT_CACHE_SIZE
.
Can be defined using stmt_cache_size
connection url parameter.
Call with None
to reset to default.
pub fn compress(self, compress: Option<Compression>) -> Self
[src]
If not None
, then client will ask for compression if server supports it
(defaults to None
).
Can be defined using compress
connection url parameter with values:
true
- library defined default compression level;fast
- library defined fast compression level;best
- library defined best compression level;0
,1
, ...,9
- explicitly defined compression level where0
stands for "no compression";
Note that compression level defined here will affect only outgoing packets.
pub fn additional_capabilities(
self,
additional_capabilities: CapabilityFlags
) -> Self
[src]
self,
additional_capabilities: CapabilityFlags
) -> 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.
pub fn connect_attrs<T1: Into<String> + Eq + Hash, T2: Into<String>>(
self,
connect_attrs: HashMap<T1, T2>
) -> Self
[src]
self,
connect_attrs: HashMap<T1, T2>
) -> Self
Connect attributes
This value is sent to the server as custom name-value attributes.
You can see them from performance_schema tables: session_account_connect_attrs
and session_connect_attrs
when all of the following conditions
are met.
- The server is MySQL 5.6 or later, or MariaDB 10.0 or later.
performance_schema
is on.performance_schema_session_connect_attrs_size
is -1 or big enough to store specified attributes.
Note
Attribute names that begin with an underscore (_
) are not set by
application programs because they are reserved for internal use.
The following attributes are sent in addition to ones set by programs.
name | value |
---|---|
_client_name | The client library name (rust-mysql-simple ) |
_client_version | The client library version |
_os | The operation system (target_os cfg feature) |
_pid | The client proces ID |
_platform | The machine platform (target_arch cfg feature) |
program_name | The first element of std::env::args if program_name isn't set by programs. |
Trait Implementations
impl Debug for OptsBuilder
[src]
impl Default for OptsBuilder
[src]
fn default() -> OptsBuilder
[src]
impl From<OptsBuilder> for Opts
[src]
fn from(builder: OptsBuilder) -> Opts
[src]
Auto Trait Implementations
impl RefUnwindSafe for OptsBuilder
impl Send for OptsBuilder
impl Sync for OptsBuilder
impl Unpin for OptsBuilder
impl UnwindSafe for OptsBuilder
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,