Struct mysql_async::OptsBuilder
source · pub struct OptsBuilder { /* private fields */ }
Expand description
Provides a way to build Opts
.
// You can use the default builder
let existing_opts = OptsBuilder::default()
.ip_or_hostname("foo")
.db_name(Some("bar"))
// ..
// Or use existing T: Into<Opts>
let builder = OptsBuilder::from(existing_opts)
.ip_or_hostname("baz")
.tcp_port(33306)
// ..
Implementations§
source§impl OptsBuilder
impl OptsBuilder
sourcepub fn ip_or_hostname<T: Into<String>>(self, ip_or_hostname: T) -> Self
pub fn ip_or_hostname<T: Into<String>>(self, ip_or_hostname: T) -> Self
Defines server IP or hostname. See Opts::ip_or_hostname
.
sourcepub fn tcp_port(self, tcp_port: u16) -> Self
pub fn tcp_port(self, tcp_port: u16) -> Self
Defines TCP port. See Opts::tcp_port
.
sourcepub fn resolved_ips<T: Into<Vec<IpAddr>>>(self, ips: Option<T>) -> Self
pub fn resolved_ips<T: Into<Vec<IpAddr>>>(self, ips: Option<T>) -> Self
Defines already-resolved IPs to use for the connection. When provided the connection will not perform DNS resolution and the hostname will be used only for TLS identity verification purposes.
sourcepub fn db_name<T: Into<String>>(self, db_name: Option<T>) -> Self
pub fn db_name<T: Into<String>>(self, db_name: Option<T>) -> Self
Defines database name. See Opts::db_name
.
sourcepub fn init<T: Into<String>>(self, init: Vec<T>) -> Self
pub fn init<T: Into<String>>(self, init: Vec<T>) -> Self
Defines initial queries. See Opts::init
.
sourcepub fn setup<T: Into<String>>(self, setup: Vec<T>) -> Self
pub fn setup<T: Into<String>>(self, setup: Vec<T>) -> Self
Defines setup queries. See Opts::setup
.
sourcepub fn tcp_keepalive<T: Into<u32>>(self, tcp_keepalive: Option<T>) -> Self
pub fn tcp_keepalive<T: Into<u32>>(self, tcp_keepalive: Option<T>) -> Self
Defines tcp_keepalive
option. See Opts::tcp_keepalive
.
sourcepub fn tcp_nodelay(self, nodelay: bool) -> Self
pub fn tcp_nodelay(self, nodelay: bool) -> Self
Defines tcp_nodelay
option. See Opts::tcp_nodelay
.
sourcepub fn local_infile_handler<T>(self, handler: Option<T>) -> Selfwhere
T: GlobalHandler,
pub fn local_infile_handler<T>(self, handler: Option<T>) -> Selfwhere
T: GlobalHandler,
Defines global LOCAL INFILE handler (see crate-level docs).
sourcepub fn pool_opts<T: Into<Option<PoolOpts>>>(self, pool_opts: T) -> Self
pub fn pool_opts<T: Into<Option<PoolOpts>>>(self, pool_opts: T) -> Self
Defines pool options. See Opts::pool_opts
.
sourcepub fn conn_ttl<T: Into<Option<Duration>>>(self, conn_ttl: T) -> Self
pub fn conn_ttl<T: Into<Option<Duration>>>(self, conn_ttl: T) -> Self
Defines connection TTL. See Opts::conn_ttl
.
sourcepub fn stmt_cache_size<T>(self, cache_size: T) -> Self
pub fn stmt_cache_size<T>(self, cache_size: T) -> Self
Defines statement cache size. See Opts::stmt_cache_size
.
sourcepub fn ssl_opts<T: Into<Option<SslOpts>>>(self, ssl_opts: T) -> Self
pub fn ssl_opts<T: Into<Option<SslOpts>>>(self, ssl_opts: T) -> Self
Defines SSL options. See Opts::ssl_opts
.
sourcepub fn prefer_socket<T: Into<Option<bool>>>(self, prefer_socket: T) -> Self
pub fn prefer_socket<T: Into<Option<bool>>>(self, prefer_socket: T) -> Self
Defines prefer_socket
option. See Opts::prefer_socket
.
sourcepub fn socket<T: Into<String>>(self, socket: Option<T>) -> Self
pub fn socket<T: Into<String>>(self, socket: Option<T>) -> Self
Defines socket path. See Opts::socket
.
sourcepub fn compression<T: Into<Option<Compression>>>(self, compression: T) -> Self
pub fn compression<T: Into<Option<Compression>>>(self, compression: T) -> Self
Defines compression. See Opts::compression
.
sourcepub fn max_allowed_packet(self, max_allowed_packet: Option<usize>) -> Self
pub fn max_allowed_packet(self, max_allowed_packet: Option<usize>) -> Self
Defines max_allowed_packet
option. See Opts::max_allowed_packet
.
Note that it’ll saturate to proper minimum and maximum values for this parameter (see MySql documentation).
sourcepub fn wait_timeout(self, wait_timeout: Option<usize>) -> Self
pub fn wait_timeout(self, wait_timeout: Option<usize>) -> Self
Defines wait_timeout
option. See Opts::wait_timeout
.
Note that it’ll saturate to proper minimum and maximum values for this parameter (see MySql documentation).
sourcepub fn secure_auth(self, secure_auth: bool) -> Self
pub fn secure_auth(self, secure_auth: bool) -> Self
Disables mysql_old_password
plugin (defaults to true
).
Available via secure_auth
connection url parameter.
sourcepub fn client_found_rows(self, client_found_rows: bool) -> Self
pub fn client_found_rows(self, client_found_rows: bool) -> Self
Enables or disables CLIENT_FOUND_ROWS
capability. See Opts::client_found_rows
.
sourcepub fn enable_cleartext_plugin(self, enable_cleartext_plugin: bool) -> Self
pub fn enable_cleartext_plugin(self, enable_cleartext_plugin: bool) -> Self
Enables Client-Side Cleartext Pluggable Authentication (defaults to false
).
Enables client to send passwords to the server as cleartext, without hashing or encryption (consult MySql documentation for more info).
§Security Notes
Sending passwords as cleartext may be a security problem in some configurations. Please consider using TLS or encrypted tunnels for server connection.
§Connection URL
Use enable_cleartext_plugin
URL parameter to set this value. E.g.
let opts = Opts::from_url("mysql://localhost/db?enable_cleartext_plugin=true")?;
assert!(opts.enable_cleartext_plugin());
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 moresource§impl Debug for OptsBuilder
impl Debug for OptsBuilder
source§impl Default for OptsBuilder
impl Default for OptsBuilder
source§impl From<OptsBuilder> for Opts
impl From<OptsBuilder> for Opts
source§fn from(builder: OptsBuilder) -> Opts
fn from(builder: OptsBuilder) -> Opts
source§impl PartialEq for OptsBuilder
impl PartialEq for OptsBuilder
impl Eq for OptsBuilder
impl StructuralPartialEq for OptsBuilder
Auto Trait Implementations§
impl Freeze for OptsBuilder
impl !RefUnwindSafe for OptsBuilder
impl Send for OptsBuilder
impl Sync for OptsBuilder
impl Unpin for OptsBuilder
impl !UnwindSafe for OptsBuilder
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<T> FmtForward for T
impl<T> FmtForward for T
source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> Tap for T
impl<T> Tap for T
source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moresource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moresource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moresource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moresource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moresource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moresource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.