mirror of
https://github.com/actix/examples
synced 2025-06-27 09:29:02 +02:00
refactor: use confik instead of config
This commit is contained in:
23
databases/postgres/src/config.rs
Normal file
23
databases/postgres/src/config.rs
Normal file
@ -0,0 +1,23 @@
|
||||
use confik::Configuration;
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Debug, Default, Configuration)]
|
||||
pub struct ExampleConfig {
|
||||
pub server_addr: String,
|
||||
#[confik(from = DbConfig)]
|
||||
pub pg: deadpool_postgres::Config,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(transparent)]
|
||||
struct DbConfig(deadpool_postgres::Config);
|
||||
|
||||
impl From<DbConfig> for deadpool_postgres::Config {
|
||||
fn from(value: DbConfig) -> Self {
|
||||
value.0
|
||||
}
|
||||
}
|
||||
|
||||
impl confik::Configuration for DbConfig {
|
||||
type Builder = Option<Self>;
|
||||
}
|
Reference in New Issue
Block a user