compiler_llvm_builder/
lock.rs1use anyhow::Context;
6use std::fs::File;
7use std::io::Read;
8use std::path::PathBuf;
9
10use serde::Deserialize;
11use serde::Serialize;
12
13#[derive(Debug, Deserialize, Serialize)]
19pub struct Lock {
20 pub url: String,
22 pub branch: String,
24 pub r#ref: Option<String>,
26}
27
28impl TryFrom<&PathBuf> for Lock {
29 type Error = anyhow::Error;
30
31 fn try_from(path: &PathBuf) -> Result<Self, Self::Error> {
32 let mut config_str = String::new();
33 let mut config_file =
34 File::open(path).with_context(|| format!("Error opening {:?} file", path))?;
35 config_file.read_to_string(&mut config_str)?;
36 Ok(toml::from_str(&config_str)?)
37 }
38}