aboutsummaryrefslogtreecommitdiff
path: root/zkvms_host_io/src
diff options
context:
space:
mode:
authorKamen Mladenov <kamen@syndamia.com>2025-02-10 15:39:06 +0200
committerKamen Mladenov <kamen@syndamia.com>2025-02-10 15:39:06 +0200
commit2ed8a2cb0d955752f2b212b6898ab58ebfb7f220 (patch)
tree14e8fd972621b7b062051ecd46449ccee0651cb9 /zkvms_host_io/src
parent35dc06a71ec230bd652166360aa8b6b89440c6d0 (diff)
downloadzkVMs-benchmarks-2ed8a2cb0d955752f2b212b6898ab58ebfb7f220.tar
zkVMs-benchmarks-2ed8a2cb0d955752f2b212b6898ab58ebfb7f220.tar.gz
zkVMs-benchmarks-2ed8a2cb0d955752f2b212b6898ab58ebfb7f220.zip
docs(zkvms_host_io): Add detailed documentation comments
Diffstat (limited to 'zkvms_host_io/src')
-rw-r--r--zkvms_host_io/src/lib.rs22
1 files changed, 21 insertions, 1 deletions
diff --git a/zkvms_host_io/src/lib.rs b/zkvms_host_io/src/lib.rs
index 3de8c5e..9448789 100644
--- a/zkvms_host_io/src/lib.rs
+++ b/zkvms_host_io/src/lib.rs
@@ -12,25 +12,32 @@ static DEFAULT_ENV: &str = include_str!(concat!(env!("INPUTS_DIR"), "/default.en
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
struct Cli {
- /// What the ZKVM is going to do
+ /// ZKVM action (execute, prove, verify)
run_type: RunType,
+ /// Path to private input file in (TOML format)
private_input: Option<String>,
+ /// Path to public input file in (TOML format)
public_input: Option<String>,
+ /// Enable benchmark timer and formatted output
#[arg(short, long)]
benchmark: bool,
+ /// Benchmark the given action multiple times
#[arg(short, long, requires = "benchmark")]
repeat: Option<usize>,
+ /// Output timings as milliseconds instead of seconds
#[arg(short, long, requires = "benchmark")]
millis: bool,
+ /// Put the benchmark's formatted output into a file of the given path
#[arg(short, long, requires = "benchmark")]
metrics_output: Option<String>,
+ /// Append the benchmark formatted output to the given file, instead of replacing it
#[arg(short, long, requires = "benchmark")]
append: bool,
}
@@ -59,6 +66,14 @@ pub struct RunWith {
}
impl RunWith {
+ /// Returns a value of the given name from the environment,
+ /// default environment or the given constant, depending on which
+ /// one exists.
+ ///
+ /// If the variable is from either environments, the `then_apply`
+ /// function is executed to convert the String value.
+ ///
+ /// The default environment is taken from the guest's `default.env`
pub fn env_then_or<T>(&self, variable_name: &str, then_apply: fn(String) -> Option<T>, else_const: T) -> T {
env::var(variable_name)
.ok()
@@ -70,6 +85,11 @@ impl RunWith {
.unwrap_or(else_const))
}
+ /// Returns a value of the given name from the environment,
+ /// default environment or the given constant, depending on which
+ /// one exists.
+ ///
+ /// The default environment is taken from the guest's `default.env`
pub fn env_or(&self, variable_name: &str, else_const: &str) -> String {
self.env_then_or(variable_name, |x| Some(x), else_const.to_string())
}