use datasize::DataSize;
use serde::{Deserialize, Serialize};
const DEFAULT_ADDRESS: &str = "0.0.0.0:0";
const DEFAULT_QPS_LIMIT: u64 = 100;
const DEFAULT_CORS_ORIGIN: &str = "";
#[derive(Clone, DataSize, Debug, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct Config {
pub enable_server: bool,
pub address: String,
pub qps_limit: u64,
pub cors_origin: String,
}
impl Config {
pub fn new() -> Self {
Config {
enable_server: true,
address: DEFAULT_ADDRESS.to_string(),
qps_limit: DEFAULT_QPS_LIMIT,
cors_origin: DEFAULT_CORS_ORIGIN.to_string(),
}
}
}
impl Default for Config {
fn default() -> Self {
Config::new()
}
}