[][src]Struct mysql_async::Opts

pub struct Opts { /* fields omitted */ }

Mysql connection options.

Build one with OptsBuilder.

Methods

impl Opts[src]

pub fn from_url(url: &str) -> Result<Opts, UrlError>[src]

pub fn ip_or_hostname(&self) -> &str[src]

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

pub fn tcp_port(&self) -> u16[src]

TCP port of mysql server (defaults to 3306).

pub fn user(&self) -> Option<&str>[src]

User (defaults to None).

Connection URL

Can be defined in connection URL. E.g.

let opts = Opts::from_url("mysql://user@localhost/database_name")?;
assert_eq!(opts.user(), Some("user"));

pub fn pass(&self) -> Option<&str>[src]

Password (defaults to None).

Connection URL

Can be defined in connection URL. E.g.

let opts = Opts::from_url("mysql://user:pass%20word@localhost/database_name")?;
assert_eq!(opts.pass(), Some("pass word"));

pub fn db_name(&self) -> Option<&str>[src]

Database name (defaults to None).

Connection URL

Database name can be defined in connection URL. E.g.

let opts = Opts::from_url("mysql://localhost/database_name")?;
assert_eq!(opts.db_name(), Some("database_name"));

pub fn init(&self) -> &[String][src]

Commands to execute on each new database connection.

pub fn tcp_keepalive(&self) -> Option<u32>[src]

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

Connection URL

You can use tcp_keepalive URL parameter to set this value (in milliseconds). E.g.

let opts = Opts::from_url("mysql://localhost/db?tcp_keepalive=10000")?;
assert_eq!(opts.tcp_keepalive(), Some(10_000));

pub fn tcp_nodelay(&self) -> bool[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.

Connection URL

You can use tcp_nodelay URL parameter to set this value. E.g.

let opts = Opts::from_url("mysql://localhost/db?tcp_nodelay=false")?;
assert_eq!(opts.tcp_nodelay(), false);

pub fn local_infile_handler(&self) -> Option<Arc<dyn LocalInfileHandler>>[src]

Handler for local infile requests (defaults to None).

pub fn pool_opts(&self) -> &PoolOpts[src]

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

pub fn conn_ttl(&self) -> Option<Duration>[src]

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

Connection URL

You can use conn_ttl URL parameter to set this value (in seconds). E.g.

let opts = Opts::from_url("mysql://localhost/db?conn_ttl=360")?;
assert_eq!(opts.conn_ttl(), Some(Duration::from_secs(360)));

pub fn stmt_cache_size(&self) -> usize[src]

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

Call with None to reset to default. Set to 0 to disable statement cache.

Caveats

If statement cache is disabled (stmt_cache_size is 0), then you must close statements manually.

Connection URL

You can use stmt_cache_size URL parameter to set this value. E.g.

let opts = Opts::from_url("mysql://localhost/db?stmt_cache_size=128")?;
assert_eq!(opts.stmt_cache_size(), 128);

pub fn ssl_opts(&self) -> Option<&SslOpts>[src]

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

pub fn prefer_socket(&self) -> bool[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 (e.g. docker).

Connection URL

You can use prefer_socket URL parameter to set this value. E.g.

let opts = Opts::from_url("mysql://localhost/db?prefer_socket=false")?;
assert_eq!(opts.prefer_socket(), false);

pub fn socket(&self) -> Option<&str>[src]

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

Connection URL

You can use socket URL parameter to set this value. E.g.

let opts = Opts::from_url("mysql://localhost/db?socket=%2Fpath%2Fto%2Fsocket")?;
assert_eq!(opts.socket(), Some("/path/to/socket"));

pub fn compression(&self) -> Option<Compression>[src]

If not None, then client will ask for compression if server supports it (defaults to None).

Connection URL

You can use compression URL parameter to set this value:

  • 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 Opts[src]

impl Debug for Opts[src]

impl Default for Opts[src]

impl Eq for Opts[src]

impl From<OptsBuilder> for Opts[src]

impl<T: AsRef<str> + Sized> From<T> for Opts[src]

impl FromStr for Opts[src]

type Err = UrlError

The associated error which can be returned from parsing.

impl PartialEq<Opts> for Opts[src]

impl StructuralEq for Opts[src]

impl StructuralPartialEq for Opts[src]

Auto Trait Implementations

impl !RefUnwindSafe for Opts

impl Send for Opts

impl Sync for Opts

impl Unpin for Opts

impl !UnwindSafe for Opts

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>,