Skip to main content

atomr_infer_cli/
config.rs

1//! Project-file (`<config>.toml`) parsing. Doc §11.3.
2
3use std::path::Path;
4
5use serde::{Deserialize, Serialize};
6
7use atomr_infer_core::deployment::Deployment;
8
9#[derive(Debug, Clone, Serialize, Deserialize)]
10pub struct ProjectFile {
11    pub cluster: ClusterConfig,
12    #[serde(default, rename = "deployment")]
13    pub deployments: Vec<Deployment>,
14}
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
17pub struct ClusterConfig {
18    pub name: String,
19    /// HTTP gateway bind address. Optional — defaults to 127.0.0.1:8080.
20    #[serde(default = "default_bind")]
21    pub bind: std::net::SocketAddr,
22    /// atomr cluster endpoint (placeholder; v0 runs single-node).
23    #[serde(default)]
24    pub endpoint: Option<String>,
25}
26
27fn default_bind() -> std::net::SocketAddr {
28    "127.0.0.1:8080".parse().expect("static addr")
29}
30
31impl ProjectFile {
32    pub fn from_path(path: impl AsRef<Path>) -> anyhow::Result<Self> {
33        let body = std::fs::read_to_string(path.as_ref())?;
34        Ok(toml::from_str(&body)?)
35    }
36}