use crate::error::{Error, Result};
use crate::spec::ProofSpec;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct Config {
pub spec: ProofSpec,
}
impl Config {
pub fn from_json(s: &str) -> Result<Self> {
let cfg: Self = serde_json::from_str(s)?;
cfg.spec.validate()?;
Ok(cfg)
}
pub fn from_toml(s: &str) -> Result<Self> {
let cfg: Self = toml::from_str(s).map_err(|e| Error::Parse(e.to_string()))?;
cfg.spec.validate()?;
Ok(cfg)
}
}