Open igotfr opened 2 years ago
Associated functions you are trying to access are deprecated since 0.12, maybe try using something like below code
use config::Config;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
pub struct ServerConfig {
pub host: String,
pub port: u16,
}
impl ServerConfig {
pub fn from_env() -> Self {
let _config = Config::builder()
.add_source(::config::Environment::default())
.build()
.unwrap();
let config: ServerConfig = _config.try_deserialize().unwrap();
config
}
}
[dependencies]
actix-web = "4"
config = "0.13.1"
Reference : Config Doc https://docs.rs/config/0.13.1/config/index.html, Official example from actix web https://github.com/actix/examples/blob/master/databases/postgres/src/main.rs
@VibhavSurve09 I'm referring the files in this repo: https://github.com/nemesiscodex/actix-todo/blob/master/src/config.rs https://github.com/nemesiscodex/actix-todo/blob/master/Cargo.toml
config.rs
Cargo.toml