use super::Client;
use super::opts;
use crate::Error;
use crate::utils;
use sqlx::postgres::PgPool;
#[cfg(doc)]
use super::ClientBuilder;
impl Client {
pub async fn connect() -> Result<Client, Error> {
let pool = utils::create_pool(None).await?;
Client::with_pool(pool).await
}
pub async fn connect_to<U>(url: U) -> Result<Client, Error>
where
U: AsRef<str>,
{
let pool = utils::create_pool(Some(url.as_ref())).await?;
Client::with_pool(pool).await
}
pub async fn with_pool(pool: PgPool) -> Result<Self, Error> {
let opts = opts::ClientOptions::default();
Ok(Client::new(pool, opts).await?)
}
}