pub enum Transport {
Tcp(TcpVariant),
Unix(UnixStream),
}Expand description
Transport layer abstraction
Variants§
Implementations§
Source§impl Transport
impl Transport
Sourcepub async fn connect_tcp(host: &str, port: u16) -> Result<Self>
pub async fn connect_tcp(host: &str, port: u16) -> Result<Self>
Sourcepub async fn connect_tcp_tls(
host: &str,
port: u16,
tls_config: &TlsConfig,
) -> Result<Self>
pub async fn connect_tcp_tls( host: &str, port: u16, tls_config: &TlsConfig, ) -> Result<Self>
Connect via TLS-encrypted TCP using PostgreSQL SSL negotiation protocol.
PostgreSQL requires a specific SSL upgrade sequence:
- Send
SSLRequestmessage (8 bytes) - Server responds with ‘S’ (accept) or ‘N’ (reject)
- If accepted, perform TLS handshake
§Errors
Returns Error::Io if the TCP connection or SSL negotiation fails.
Returns Error::Config if the server rejects SSL, sends an unexpected response,
the hostname is invalid for TLS, or the TLS handshake fails.
Sourcepub async fn connect_unix(path: &Path) -> Result<Self>
pub async fn connect_unix(path: &Path) -> Result<Self>
Sourcepub fn apply_keepalive(&self, idle: Duration) -> Result<()>
pub fn apply_keepalive(&self, idle: Duration) -> Result<()>
Apply TCP keepalive to this transport, if it is a TCP connection.
A no-op for Unix socket transports (keepalive is a TCP-layer feature).
Logs a warning and returns Ok(()) rather than failing if the platform
does not support the requested keepalive interval.
§Errors
Returns Error::Io if setting the TCP keepalive option fails.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Transport
impl !RefUnwindSafe for Transport
impl Send for Transport
impl Sync for Transport
impl Unpin for Transport
impl UnsafeUnpin for Transport
impl !UnwindSafe for Transport
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