Skip to main content

wickra_proof_core/
config.rs

1//! [`Config`] — a `ProofSpec` loaded from a CLI file (JSON or TOML).
2
3use crate::error::{Error, Result};
4use crate::spec::ProofSpec;
5use serde::{Deserialize, Serialize};
6
7/// A thin wrapper around a [`ProofSpec`] for CLI file loading.
8#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
9pub struct Config {
10    /// The proof job.
11    pub spec: ProofSpec,
12}
13
14impl Config {
15    /// Load a `Config` from JSON.
16    pub fn from_json(s: &str) -> Result<Self> {
17        let cfg: Self = serde_json::from_str(s)?;
18        cfg.spec.validate()?;
19        Ok(cfg)
20    }
21
22    /// Load a `Config` from TOML.
23    pub fn from_toml(s: &str) -> Result<Self> {
24        let cfg: Self = toml::from_str(s).map_err(|e| Error::Parse(e.to_string()))?;
25        cfg.spec.validate()?;
26        Ok(cfg)
27    }
28}