summaryrefslogtreecommitdiff
path: root/src/users.rs
blob: b7c11bdb0ec0b532b5c38a57d9923b93681fcbe3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use std::collections::BTreeMap;
use std::fs::read_to_string;
use std::path::PathBuf;
use serde_derive::Deserialize;
use toml;
use anyhow;

#[derive(Deserialize)]
pub struct RcTestGroup {
    pub max_commits:        u64,
    pub priority:           u64,
    pub tests:              Vec<PathBuf>,
}

#[derive(Deserialize)]
pub struct RcBranch {
    pub fetch:              String,
    pub tests:              Vec<String>,
}

#[derive(Deserialize)]
pub struct Userrc {
    pub test_group:         BTreeMap<String, RcTestGroup>,
    pub branch:             BTreeMap<String, RcBranch>,
}

pub fn userrc_read(path: &PathBuf) -> anyhow::Result<Userrc> {
    let config = read_to_string(path)?;
    let rc: Userrc = toml::from_str(&config)?;

    Ok(rc)
}