pub struct PgConnectionBuilder { /* private fields */ }Expand description
Builder for configuring and establishing a PostgreSQL connection.
§Example
use oxisql_postgres::{PgConnectionBuilder, TlsMode};
let conn = PgConnectionBuilder::new()
.host("localhost")
.port(5432)
.dbname("mydb")
.user("postgres")
.password("secret")
.connect()
.await?;Implementations§
Source§impl PgConnectionBuilder
impl PgConnectionBuilder
Sourcepub fn connect_timeout_secs(self, secs: u64) -> Self
pub fn connect_timeout_secs(self, secs: u64) -> Self
Set the connection timeout in seconds.
Sourcepub fn tls_skip_verify(self) -> Result<Self, PgError>
pub fn tls_skip_verify(self) -> Result<Self, PgError>
Require TLS but skip server certificate verification.
INSECURE — intended for development and testing environments only.
Production code should use tls_with_ca_pem or
supply a trusted root certificate store via
tls_mode with a fully validated
TlsMode::Rustls config.
Internally calls TlsMode::skip_verify to build a ClientConfig
that accepts all server certificates without validation.
§Errors
Returns PgError::Tls if the rustls ClientConfig cannot be built.
Sourcepub fn tls_with_ca_pem(self, ca_pem: Vec<u8>) -> Result<Self, PgError>
pub fn tls_with_ca_pem(self, ca_pem: Vec<u8>) -> Result<Self, PgError>
Require TLS and verify the server certificate against a custom CA.
ca_pem must be a PEM-encoded certificate authority certificate.
Multiple certificates may be concatenated in a single Vec<u8>.
Internally calls TlsMode::with_ca_pem to build a ClientConfig
that trusts the supplied CA in addition to the Mozilla WebPKI bundle.
§Errors
Returns PgError::Tls if the PEM cannot be parsed or is empty.
Sourcepub async fn connect(self) -> Result<PgConnection, PgError>
pub async fn connect(self) -> Result<PgConnection, PgError>
Establish the connection.