Skip to main content

arcbox_boot/
upstream.rs

1use std::collections::BTreeMap;
2
3use serde::Deserialize;
4
5/// Root structure of `upstream.toml`.
6#[derive(Debug, Clone, Deserialize)]
7pub struct UpstreamConfig {
8    pub binaries: Vec<UpstreamBinary>,
9}
10
11/// A single upstream binary declaration.
12#[derive(Debug, Clone, Deserialize)]
13pub struct UpstreamBinary {
14    pub name: String,
15    pub version: String,
16    /// Per-architecture source definitions.
17    pub source: BTreeMap<String, UpstreamSource>,
18}
19
20/// Where to download a binary for a specific architecture.
21#[derive(Debug, Clone, Deserialize)]
22pub struct UpstreamSource {
23    /// Download URL (typically a .tar.gz or .tgz).
24    pub url: String,
25    /// Path inside the archive to extract (e.g. "docker/dockerd").
26    pub extract: String,
27}
28
29impl UpstreamConfig {
30    pub fn from_file(path: &std::path::Path) -> Result<Self, String> {
31        let content = std::fs::read_to_string(path)
32            .map_err(|e| format!("failed to read {}: {e}", path.display()))?;
33        toml::from_str(&content).map_err(|e| format!("failed to parse {}: {e}", path.display()))
34    }
35}