use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(default)]
pub struct DashConfig {
pub host: String,
pub port: u16,
pub api_url: String,
pub torc_bin: String,
pub torc_server_bin: String,
pub standalone: bool,
pub server_port: u16,
pub server_host: String,
pub database: Option<String>,
#[cfg(unix)]
pub socket: Option<String>,
pub completion_check_interval_secs: u32,
}
impl Default for DashConfig {
fn default() -> Self {
Self {
host: "127.0.0.1".to_string(),
port: 8090,
api_url: "http://localhost:8080/torc-service/v1".to_string(),
torc_bin: "torc".to_string(),
torc_server_bin: "torc-server".to_string(),
standalone: false,
server_port: 0,
server_host: "0.0.0.0".to_string(),
database: None,
#[cfg(unix)]
socket: None,
completion_check_interval_secs: 5,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_dash_config_defaults() {
let config = DashConfig::default();
assert_eq!(config.host, "127.0.0.1");
assert_eq!(config.port, 8090);
assert_eq!(
config.api_url,
"http://localhost:8080/torc-service/v1".to_string()
);
assert_eq!(config.torc_bin, "torc");
assert_eq!(config.torc_server_bin, "torc-server");
assert!(!config.standalone);
assert_eq!(config.server_port, 0);
assert_eq!(config.server_host, "0.0.0.0");
assert!(config.database.is_none());
#[cfg(unix)]
assert!(config.socket.is_none());
assert_eq!(config.completion_check_interval_secs, 5);
}
}