1use failure::Error;
4use std::env;
5use std::fs::File;
6use std::io::prelude::*;
7use toml;
8
9#[derive(Deserialize)]
11pub struct Root {
12 pub target: String,
14 pub test_target: String,
16 pub test_cross_compile: Option<String>,
18 pub openocd: Option<Openocd>,
20 pub itm: Option<Itm>,
22}
23
24#[derive(Deserialize)]
26pub struct Openocd {
27 pub config: Vec<String>,
29}
30
31#[derive(Deserialize)]
33pub struct Itm {
34 pub frequency: u32,
36}
37
38pub fn read() -> Result<Root, Error> {
40 let path = env::current_dir()?.join("Drone.toml");
41 let mut buffer = String::new();
42 let mut file = File::open(&path)?;
43 file.read_to_string(&mut buffer)?;
44 Ok(toml::from_str(&buffer)?)
45}