1use rill_protocol::config::ConfigPatch;
4use serde::Deserialize;
5use std::net::IpAddr;
6
7pub static SERVER_ADDRESS: ConfigPatch<IpAddr> = ConfigPatch::new("RILLRATE_SERVER_ADDRESS");
9
10#[derive(Deserialize, Debug)]
12pub struct ServerConfig {
13 pub address: Option<IpAddr>,
15}
16
17impl Default for ServerConfig {
18 fn default() -> Self {
19 Self { address: None }
20 }
21}
22
23impl ServerConfig {
24 pub fn server_address(&self) -> IpAddr {
26 SERVER_ADDRESS.get(|| self.address, || "127.0.0.1".parse().unwrap())
27 }
28}