Struct ConnectOptions
pub struct ConnectOptions { /* private fields */ }Expand description
Defines the configuration options of a database
Implementations§
§impl ConnectOptions
impl ConnectOptions
pub fn new<T>(url: T) -> Self
pub fn new<T>(url: T) -> Self
Create new ConnectOptions for a Database by passing in a URI string
pub fn max_connections(&mut self, value: u32) -> &mut Self
pub fn max_connections(&mut self, value: u32) -> &mut Self
Set the maximum number of connections of the pool
pub fn get_max_connections(&self) -> Option<u32>
pub fn get_max_connections(&self) -> Option<u32>
Get the maximum number of connections of the pool, if set
pub fn min_connections(&mut self, value: u32) -> &mut Self
pub fn min_connections(&mut self, value: u32) -> &mut Self
Set the minimum number of connections of the pool
pub fn get_min_connections(&self) -> Option<u32>
pub fn get_min_connections(&self) -> Option<u32>
Get the minimum number of connections of the pool, if set
pub fn connect_timeout(&mut self, value: Duration) -> &mut Self
pub fn connect_timeout(&mut self, value: Duration) -> &mut Self
Set the timeout duration when acquiring a connection
pub fn get_connect_timeout(&self) -> Option<Duration>
pub fn get_connect_timeout(&self) -> Option<Duration>
Get the timeout duration when acquiring a connection, if set
pub fn idle_timeout<T>(&mut self, value: T) -> &mut Self
pub fn idle_timeout<T>(&mut self, value: T) -> &mut Self
Set the idle duration before closing a connection.
pub fn get_idle_timeout(&self) -> Option<Option<Duration>>
pub fn get_idle_timeout(&self) -> Option<Option<Duration>>
Get the idle duration before closing a connection, if set
pub fn acquire_timeout(&mut self, value: Duration) -> &mut Self
pub fn acquire_timeout(&mut self, value: Duration) -> &mut Self
Set the maximum amount of time to spend waiting for acquiring a connection
pub fn get_acquire_timeout(&self) -> Option<Duration>
pub fn get_acquire_timeout(&self) -> Option<Duration>
Get the maximum amount of time to spend waiting for acquiring a connection
pub fn max_lifetime<T>(&mut self, lifetime: T) -> &mut Self
pub fn max_lifetime<T>(&mut self, lifetime: T) -> &mut Self
Set the maximum lifetime of individual connections.
pub fn get_max_lifetime(&self) -> Option<Option<Duration>>
pub fn get_max_lifetime(&self) -> Option<Option<Duration>>
Get the maximum lifetime of individual connections, if set
pub fn sqlx_logging(&mut self, value: bool) -> &mut Self
pub fn sqlx_logging(&mut self, value: bool) -> &mut Self
Enable SQLx statement logging (default true)
pub fn get_sqlx_logging(&self) -> bool
pub fn get_sqlx_logging(&self) -> bool
Get whether SQLx statement logging is enabled
pub fn sqlx_logging_level(&mut self, level: LevelFilter) -> &mut Self
pub fn sqlx_logging_level(&mut self, level: LevelFilter) -> &mut Self
Set SQLx statement logging level (default INFO).
(ignored if sqlx_logging is false)
pub fn sqlx_slow_statements_logging_settings(
&mut self,
level: LevelFilter,
duration: Duration,
) -> &mut Self
pub fn sqlx_slow_statements_logging_settings( &mut self, level: LevelFilter, duration: Duration, ) -> &mut Self
Set SQLx slow statements logging level and duration threshold (default LevelFilter::Off).
(ignored if sqlx_logging is false)
pub fn get_sqlx_logging_level(&self) -> LevelFilter
pub fn get_sqlx_logging_level(&self) -> LevelFilter
Get the level of SQLx statement logging
pub fn get_sqlx_slow_statements_logging_settings(
&self,
) -> (LevelFilter, Duration)
pub fn get_sqlx_slow_statements_logging_settings( &self, ) -> (LevelFilter, Duration)
Get the SQLx slow statements logging settings
pub fn sqlcipher_key<T>(&mut self, value: T) -> &mut Self
pub fn sqlcipher_key<T>(&mut self, value: T) -> &mut Self
set key for sqlcipher
pub fn set_schema_search_path<T>(&mut self, schema_search_path: T) -> &mut Self
pub fn set_schema_search_path<T>(&mut self, schema_search_path: T) -> &mut Self
Set schema search path (PostgreSQL only)
pub fn set_application_name<T>(&mut self, application_name: T) -> &mut Self
pub fn set_application_name<T>(&mut self, application_name: T) -> &mut Self
Set application name (PostgreSQL only)
pub fn test_before_acquire(&mut self, value: bool) -> &mut Self
pub fn test_before_acquire(&mut self, value: bool) -> &mut Self
If true, the connection will be pinged upon acquiring from the pool (default true).
pub fn connect_lazy(&mut self, value: bool) -> &mut Self
pub fn connect_lazy(&mut self, value: bool) -> &mut Self
If set to true, the db connection pool will be created using SQLx’s
connect_lazy method.
pub fn get_connect_lazy(&self) -> bool
pub fn get_connect_lazy(&self) -> bool
Get whether DB connections will be established when the pool is created or only as needed.
pub fn after_connect<F>(&mut self, f: F) -> &mut Self
pub fn after_connect<F>(&mut self, f: F) -> &mut Self
Set a callback function that will be called after a new connection is established.
pub fn map_sqlx_mysql_opts<F>(&mut self, f: F) -> &mut Self
pub fn map_sqlx_mysql_opts<F>(&mut self, f: F) -> &mut Self
Apply a function to modify the underlying MySqlConnectOptions before
creating the connection pool.
pub fn map_sqlx_postgres_opts<F>(&mut self, f: F) -> &mut Self
pub fn map_sqlx_postgres_opts<F>(&mut self, f: F) -> &mut Self
Apply a function to modify the underlying PgConnectOptions before
creating the connection pool.
pub fn map_sqlx_sqlite_opts<F>(&mut self, f: F) -> &mut Self
pub fn map_sqlx_sqlite_opts<F>(&mut self, f: F) -> &mut Self
Apply a function to modify the underlying SqliteConnectOptions before
creating the connection pool.
§impl ConnectOptions
impl ConnectOptions
pub fn sqlx_pool_options<DB>(self) -> PoolOptions<DB>where
DB: Database,
pub fn sqlx_pool_options<DB>(self) -> PoolOptions<DB>where
DB: Database,
Convert ConnectOptions into sqlx::pool::PoolOptions
§impl ConnectOptions
impl ConnectOptions
pub fn sqlz_pool_options<DB>(self) -> PoolOptions<DB>where
DB: Database,
pub fn sqlz_pool_options<DB>(self) -> PoolOptions<DB>where
DB: Database,
Convert ConnectOptions into sqlz::pool::PoolOptions
Trait Implementations§
§impl Clone for ConnectOptions
impl Clone for ConnectOptions
§fn clone(&self) -> ConnectOptions
fn clone(&self) -> ConnectOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for ConnectOptions
impl Debug for ConnectOptions
§impl<T> From<T> for ConnectOptions
impl<T> From<T> for ConnectOptions
§fn from(s: T) -> ConnectOptions
fn from(s: T) -> ConnectOptions
Auto Trait Implementations§
impl Freeze for ConnectOptions
impl !RefUnwindSafe for ConnectOptions
impl Send for ConnectOptions
impl Sync for ConnectOptions
impl Unpin for ConnectOptions
impl !UnwindSafe for ConnectOptions
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§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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more