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
use rill_protocol::config::ConfigPatch;
use serde::Deserialize;
use std::net::IpAddr;
pub static SERVER_ADDRESS: ConfigPatch<IpAddr> = ConfigPatch::new("RILLRATE_SERVER_ADDRESS");
#[derive(Deserialize, Debug)]
pub struct ServerConfig {
pub address: Option<IpAddr>,
}
impl Default for ServerConfig {
fn default() -> Self {
Self { address: None }
}
}
impl ServerConfig {
pub fn server_address(&self) -> IpAddr {
SERVER_ADDRESS.get(|| self.address, || "127.0.0.1".parse().unwrap())
}
}