wickra_proof_core/
config.rs1use crate::error::{Error, Result};
4use crate::spec::ProofSpec;
5use serde::{Deserialize, Serialize};
6
7#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
9pub struct Config {
10 pub spec: ProofSpec,
12}
13
14impl Config {
15 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 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}