1use std::collections::BTreeMap;
2
3use serde::Deserialize;
4
5#[derive(Debug, Clone, Deserialize)]
7pub struct UpstreamConfig {
8 pub binaries: Vec<UpstreamBinary>,
9}
10
11#[derive(Debug, Clone, Deserialize)]
13pub struct UpstreamBinary {
14 pub name: String,
15 pub version: String,
16 pub source: BTreeMap<String, UpstreamSource>,
18}
19
20#[derive(Debug, Clone, Deserialize)]
22pub struct UpstreamSource {
23 pub url: String,
25 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}