[][src]Function roa_pg::connect_tls

pub async fn connect_tls<'_>(
    config: &'_ Config,
    tls_config: ClientConfig
) -> Result<(Client, Connection<AsyncStream<TcpStream>, TlsStream<AsyncStream<TcpStream>>>)>

Connect to postgres server with tls.

use roa_pg::{Client, connect_tls, ClientConfig};
use std::error::Error;
use async_std::task::spawn;

async fn play() -> Result<(), Box<dyn Error>> {
    let url = "host=localhost user=postgres";
    let (client, conn) = connect_tls(&url.parse()?, ClientConfig::new()).await?;
    spawn(conn);
    let row = client.query_one("SELECT * FROM user WHERE id=$1", &[&0]).await?;
    let value: &str = row.get(0);
    println!("value: {}", value);
    Ok(())
}