prebuilt-down 0.1.3

A CLI tool for resolve prebuilt binary dependencies
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use anyhow::{Context, Result};
use std::fs;
use std::path::Path;

use super::{Config, ConfigMap};

pub fn load_configs(path: &Path) -> Result<Vec<Config>> {
    let content = fs::read_to_string(path)
        .with_context(|| format!("failed to read config file: {}", path.display()))?;
    let config_map: ConfigMap = toml::from_str(&content)
        .with_context(|| format!("failed to parse config toml: {}", path.display()))?;
    let configs: Vec<Config> = config_map
        .into_iter()
        .map(|config_pair| Config::from(config_pair))
        .collect();
    return Ok(configs);
}