Skip to content

Commit

Permalink
generic config input over TryFrom trait. (#974)
Browse files Browse the repository at this point in the history
  • Loading branch information
fakeshadow authored Mar 9, 2024
1 parent 3da3650 commit 4309a6d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions postgres/src/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,13 @@ impl Spawner {
}

impl SharedClient {
pub async fn new(config: Config) -> Result<Self, Error> {
let (cli, drv) = connect(&mut config.clone()).await?;
pub async fn new<C>(config: C) -> Result<Self, Error>
where
Config: TryFrom<C>,
Error: From<<Config as TryFrom<C>>::Error>,
{
let mut config = Config::try_from(config)?;
let (cli, drv) = connect(&mut config).await?;

tokio::task::spawn(drv.into_future());

Expand Down

0 comments on commit 4309a6d

Please sign in to comment.