Software-only show-control readiness baseline
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
mod model;
|
||||
mod validation;
|
||||
|
||||
pub use model::*;
|
||||
pub use validation::*;
|
||||
|
||||
use std::{fs, path::Path};
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum ProjectLoadError {
|
||||
#[error("failed to read project config: {0}")]
|
||||
Io(#[from] std::io::Error),
|
||||
#[error("failed to parse project config: {0}")]
|
||||
Parse(#[from] toml::de::Error),
|
||||
}
|
||||
|
||||
impl ProjectConfig {
|
||||
pub fn from_toml_str(raw: &str) -> Result<Self, toml::de::Error> {
|
||||
toml::from_str(raw)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn load_project_from_path(path: impl AsRef<Path>) -> Result<ProjectConfig, ProjectLoadError> {
|
||||
let raw = fs::read_to_string(path)?;
|
||||
ProjectConfig::from_toml_str(&raw).map_err(ProjectLoadError::from)
|
||||
}
|
||||
Reference in New Issue
Block a user