19 lines
436 B
Rust
19 lines
436 B
Rust
use config::{Config, ConfigError, File};
|
|
use serde::Deserialize;
|
|
use std::path::{Path, PathBuf};
|
|
|
|
#[derive(Debug, Deserialize, Clone)]
|
|
pub struct GeoffreyAPIConfig {
|
|
pub db_path: PathBuf,
|
|
pub host: String,
|
|
}
|
|
|
|
impl GeoffreyAPIConfig {
|
|
pub fn new(config_path: &Path) -> Result<Self, ConfigError> {
|
|
let mut cfg = Config::new();
|
|
cfg.merge(File::from(config_path.to_path_buf()))?;
|
|
|
|
cfg.try_into()
|
|
}
|
|
}
|