pub struct PgConfig { /* private fields */ }Expand description
Postgres configuration
Implementations§
Source§impl PgConfig
impl PgConfig
Sourcepub fn new(
conn_str: &str,
tls_mode: Option<&str>,
max_connections: Option<usize>,
connection_timeout_secs: Option<u64>,
) -> Self
pub fn new( conn_str: &str, tls_mode: Option<&str>, max_connections: Option<usize>, connection_timeout_secs: Option<u64>, ) -> Self
Create a new PgConfig with explicit TLS mode, pool size, and timeout.
tls_mode accepts the same strings as the configuration file:
"disable", "prefer", "allow", "require", "verify-ca",
"verify-full". When None, the TLS mode is inferred from
sslmode= in the connection URL. With neither setting, TLS is disabled.
Invalid modes and TLS connector errors are returned when validating or connecting.
allow uses the same opportunistic TLS policy as prefer.
Sourcepub fn validate(&self) -> Result<(), Error>
pub fn validate(&self) -> Result<(), Error>
Validate connection parameters and construct the configured TLS connector.
Does not open a connection or verify the server’s certificate. Uses the same TLS policy and connector construction as connection establishment.
Sourcepub fn has_same_tls_policy(&self, other: &Self) -> Result<bool, Error>
pub fn has_same_tls_policy(&self, other: &Self) -> Result<bool, Error>
Compare effective TLS policies, including certificate verification requirements.
Resolves explicit modes, URL modes, and defaults using the connection policy. Invalid settings return an error. Does not connect or construct TLS connectors.