-
Notifications
You must be signed in to change notification settings - Fork 396
Expand file tree
/
Copy pathconfig.rs
More file actions
29 lines (26 loc) · 813 Bytes
/
config.rs
File metadata and controls
29 lines (26 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use std::{fs::File, io::Read};
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Config {
pub ip: String,
pub port: u16,
pub db_connection_urls: Vec<String>,
pub network: String,
pub max_daily_proofs_per_user: i64,
pub gateway_metrics_port: u16,
#[cfg(feature = "tls")]
pub tls_cert_path: String,
#[cfg(feature = "tls")]
pub tls_key_path: String,
#[cfg(feature = "tls")]
pub tls_port: u16,
}
impl Config {
pub fn from_file(file_path: &str) -> Result<Config, Box<dyn std::error::Error>> {
let mut file = File::open(file_path)?;
let mut contents = String::new();
file.read_to_string(&mut contents)?;
let config: Config = serde_yaml::from_str(&contents)?;
Ok(config)
}
}