pub struct PostgresConfigBuilder {Show 14 fields
pub host: String,
pub port: u16,
pub user: String,
pub password: Option<String>,
pub database: String,
pub application_name: Option<String>,
pub connect_timeout: Option<u64>,
pub ssl_mode: Option<String>,
pub pool_max_size: Option<u32>,
pub pool_min_idle: Option<u32>,
pub pool_idle_timeout: Option<Duration>,
pub pool_connection_timeout: Option<Duration>,
pub pool_max_lifetime: Option<Duration>,
pub use_pool: bool,
}
Expand description
PostgreSQL connection configuration builder
This struct is used to build a PostgreSQL connection configuration. It follows the builder pattern to allow for flexible configuration.
Fields§
§host: String
§port: u16
§user: String
§password: Option<String>
§database: String
§application_name: Option<String>
§connect_timeout: Option<u64>
§ssl_mode: Option<String>
§pool_max_size: Option<u32>
§pool_min_idle: Option<u32>
§pool_idle_timeout: Option<Duration>
§pool_connection_timeout: Option<Duration>
§pool_max_lifetime: Option<Duration>
§use_pool: bool
Implementations§
Source§impl PostgresConfigBuilder
impl PostgresConfigBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new PostgreSQL connection configuration builder with default values
Sourcepub fn application_name(self, application_name: &str) -> Self
pub fn application_name(self, application_name: &str) -> Self
Set the application name for the PostgreSQL connection
Sourcepub fn connect_timeout(self, seconds: u64) -> Self
pub fn connect_timeout(self, seconds: u64) -> Self
Set the connection timeout in seconds
Sourcepub fn pool_max_size(self, size: u32) -> Self
pub fn pool_max_size(self, size: u32) -> Self
Set the maximum size of the connection pool
Sourcepub fn pool_min_idle(self, size: u32) -> Self
pub fn pool_min_idle(self, size: u32) -> Self
Set the minimum number of idle connections in the pool
Sourcepub fn pool_idle_timeout(self, timeout: Duration) -> Self
pub fn pool_idle_timeout(self, timeout: Duration) -> Self
Set the idle timeout for connections in the pool
Sourcepub fn pool_connection_timeout(self, timeout: Duration) -> Self
pub fn pool_connection_timeout(self, timeout: Duration) -> Self
Set the connection timeout for the pool
Sourcepub fn pool_max_lifetime(self, lifetime: Duration) -> Self
pub fn pool_max_lifetime(self, lifetime: Duration) -> Self
Set the maximum lifetime of connections in the pool
Sourcepub fn build_connection_string(&self) -> String
pub fn build_connection_string(&self) -> String
Build the connection string from the configuration
Sourcepub fn build(&self) -> Result<Client, PostgresError>
pub fn build(&self) -> Result<Client, PostgresError>
Build a PostgreSQL client from the configuration
Sourcepub fn build_pool(
&self,
) -> Result<Pool<PostgresConnectionManager<NoTls>>, Error>
pub fn build_pool( &self, ) -> Result<Pool<PostgresConnectionManager<NoTls>>, Error>
Build a PostgreSQL connection pool from the configuration
Trait Implementations§
Source§impl Debug for PostgresConfigBuilder
impl Debug for PostgresConfigBuilder
Auto Trait Implementations§
impl Freeze for PostgresConfigBuilder
impl RefUnwindSafe for PostgresConfigBuilder
impl Send for PostgresConfigBuilder
impl Sync for PostgresConfigBuilder
impl Unpin for PostgresConfigBuilder
impl UnwindSafe for PostgresConfigBuilder
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
Mutably borrows from an owned value. Read more