From 6e3ef85fd7b9e2e97583105a28a5a863527cfe59 Mon Sep 17 00:00:00 2001 From: Kamen Mladenov Date: Tue, 28 Jan 2025 13:04:02 +0200 Subject: feat(zkvms_host_io): Generate input type from string and read input data from TOML file --- zkvms_host_io/src/lib.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'zkvms_host_io/src') diff --git a/zkvms_host_io/src/lib.rs b/zkvms_host_io/src/lib.rs index 29723db..74c3992 100644 --- a/zkvms_host_io/src/lib.rs +++ b/zkvms_host_io/src/lib.rs @@ -1,11 +1,16 @@ use clap::{Parser, ValueEnum}; use num_traits::NumCast; +use serde::{ Serialize, Deserialize }; +pub use input_macros::foreach_input_field; #[derive(Parser, Debug)] #[command(version, about, long_about = None)] struct Cli { /// What the ZKVM is going to do run_type: RunType, + + #[arg(default_value = "./public_input.toml")] + public_input: String, } #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum)] @@ -21,15 +26,15 @@ pub struct RunWith { pub input: T, } -fn read_input() -> (Vec>, u32, Vec>) { - include!(env!("INPUTS")) -} +input_macros::generate_input_struct!(); -pub fn read_args() -> RunWith<(Vec>, u32, Vec>)> { +pub fn read_args() -> RunWith { let cli = Cli::parse(); + let val: Input = toml::from_str(&std::fs::read_to_string(cli.public_input).unwrap()).unwrap(); + RunWith { run_type: cli.run_type, - input: read_input(), + input: val, } } -- cgit v1.2.3