pub struct PgConnection { /* private fields */ }Expand description
PostgreSQL connection.
Manages a TCP connection to a PostgreSQL server, handling the wire protocol, authentication, and state tracking.
§Console Support
When the console feature is enabled, the connection can report progress
via an attached SqlModelConsole. This provides rich feedback during
connection establishment and query execution.
Implementations§
Source§impl PgConnection
impl PgConnection
Sourcepub fn connect(config: PgConfig) -> Result<Self, Error>
pub fn connect(config: PgConfig) -> Result<Self, Error>
Establish a new connection to the PostgreSQL server.
This performs the complete connection handshake:
- TCP connection
- SSL negotiation (if configured)
- Startup message
- Authentication
- Receive server parameters and ReadyForQuery
Sourcepub fn state(&self) -> ConnectionState
pub fn state(&self) -> ConnectionState
Get the current connection state.
Sourcepub fn process_id(&self) -> i32
pub fn process_id(&self) -> i32
Get the backend process ID (for query cancellation).
Sourcepub fn secret_key(&self) -> i32
pub fn secret_key(&self) -> i32
Get the secret key (for query cancellation).
Sourcepub fn parameters(&self) -> &HashMap<String, String>
pub fn parameters(&self) -> &HashMap<String, String>
Get all server parameters.
Trait Implementations§
Source§impl Debug for PgConnection
impl Debug for PgConnection
Auto Trait Implementations§
impl Freeze for PgConnection
impl RefUnwindSafe for PgConnection
impl Send for PgConnection
impl Sync for PgConnection
impl Unpin for PgConnection
impl UnwindSafe for PgConnection
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> 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).