[][src]Struct mysql_async::OptsBuilder

pub struct OptsBuilder { /* fields omitted */ }

Provides a way to build Opts.

This example is not tested
// 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]

pub fn new() -> Self[src]

pub fn from_opts<T: Into<Opts>>(opts: T) -> Self[src]

pub fn ip_or_hostname<T: Into<String>>(
    &mut self,
    ip_or_hostname: T
) -> &mut Self
[src]

Address of mysql server (defaults to 127.0.0.1). Hostnames should also work.

pub fn tcp_port(&mut self, tcp_port: u16) -> &mut Self[src]

TCP port of mysql server (defaults to 3306).

pub fn user<T: Into<String>>(&mut self, user: Option<T>) -> &mut Self[src]

User (defaults to None).

pub fn pass<T: Into<String>>(&mut self, pass: Option<T>) -> &mut Self[src]

Password (defaults to None).

pub fn db_name<T: Into<String>>(&mut self, db_name: Option<T>) -> &mut Self[src]

Database name (defaults to None).

pub fn init<T: Into<String>>(&mut self, init: Vec<T>) -> &mut Self[src]

Commands to execute on each new database connection.

pub fn tcp_keepalive<T: Into<u32>>(
    &mut self,
    tcp_keepalive: Option<T>
) -> &mut Self
[src]

TCP keep alive timeout in milliseconds (defaults to None).

pub fn tcp_nodelay(&mut self, nodelay: bool) -> &mut 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 local_infile_handler<T>(&mut self, handler: Option<T>) -> &mut Self where
    T: LocalInfileHandler + 'static, 
[src]

Handler for local infile requests (defaults to None).

pub fn pool_options<T: Into<Option<PoolOptions>>>(
    &mut self,
    pool_options: T
) -> &mut Self
[src]

Connection pool options (defaults to PoolOptions::default()).

pub fn conn_ttl<T: Into<Option<Duration>>>(&mut self, conn_ttl: T) -> &mut Self[src]

Pool will close connection if time since last IO exceeds this number of seconds (defaults to wait_timeout. None to reset to default).

pub fn stmt_cache_size<T>(&mut self, cache_size: T) -> &mut Self where
    T: Into<Option<usize>>, 
[src]

Number of prepared statements cached on the client side (per connection). Defaults to 10.

Call with None to reset to default.

pub fn ssl_opts<T: Into<Option<SslOpts>>>(&mut self, ssl_opts: T) -> &mut Self[src]

Driver will require SSL connection if this option isn't None (default to None).

pub fn prefer_socket<T: Into<Option<bool>>>(
    &mut self,
    prefer_socket: T
) -> &mut Self
[src]

Prefer socket connection (defaults to true).

Will reconnect via socket (or 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.

Note

Library will query the @@socket server variable to get socket address, and this address may be incorrect in some cases (i.e. docker).

pub fn socket<T: Into<String>>(&mut self, socket: Option<T>) -> &mut Self[src]

Path to unix socket (or named pipe on Windows) (defaults to None).

pub fn compression<T: Into<Option<Compression>>>(
    &mut self,
    compression: T
) -> &mut 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:

  • fast - for compression level 1;
  • best - for compression level 9;
  • on, true - for default compression level;
  • 0, ..., 9.

Note that compression level defined here will affect only outgoing packets.

Trait Implementations

impl Clone for OptsBuilder[src]

impl Debug for OptsBuilder[src]

impl Default for OptsBuilder[src]

impl Eq for OptsBuilder[src]

impl From<OptsBuilder> for Opts[src]

impl PartialEq<OptsBuilder> for OptsBuilder[src]

impl StructuralEq for OptsBuilder[src]

impl StructuralPartialEq for OptsBuilder[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,