pub struct PgConfig {
pub host: String,
pub port: u16,
pub user: String,
pub password: Option<String>,
pub database: String,
pub application_name: Option<String>,
pub connect_timeout: Duration,
pub ssl_mode: SslMode,
pub options: HashMap<String, String>,
}Expand description
PostgreSQL connection configuration.
Fields§
§host: StringHostname or IP address
port: u16Port number (default: 5432)
user: StringUsername for authentication
password: Option<String>Password for authentication (optional for trust auth)
database: StringDatabase name to connect to
application_name: Option<String>Application name (visible in pg_stat_activity)
connect_timeout: DurationConnection timeout
ssl_mode: SslModeSSL mode
options: HashMap<String, String>Additional connection parameters
Implementations§
Source§impl PgConfig
impl PgConfig
Sourcepub fn new(
host: impl Into<String>,
user: impl Into<String>,
database: impl Into<String>,
) -> Self
pub fn new( host: impl Into<String>, user: impl Into<String>, database: impl Into<String>, ) -> Self
Create a new configuration with the given connection string components.
Sourcepub fn application_name(self, name: impl Into<String>) -> Self
pub fn application_name(self, name: impl Into<String>) -> Self
Set the application name.
Sourcepub fn connect_timeout(self, timeout: Duration) -> Self
pub fn connect_timeout(self, timeout: Duration) -> Self
Set the connection timeout.
Sourcepub fn option(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn option(self, key: impl Into<String>, value: impl Into<String>) -> Self
Set an additional connection option.
Sourcepub fn startup_params(&self) -> Vec<(String, String)>
pub fn startup_params(&self) -> Vec<(String, String)>
Build the startup parameters to send to the server.
Sourcepub fn socket_addr(&self) -> String
pub fn socket_addr(&self) -> String
Get the socket address string for connection.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PgConfig
impl RefUnwindSafe for PgConfig
impl Send for PgConfig
impl Sync for PgConfig
impl Unpin for PgConfig
impl UnwindSafe for PgConfig
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
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: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).