Skip to content

Commit

Permalink
fix: make PostprocessingLevel ValueEnum
Browse files Browse the repository at this point in the history
  • Loading branch information
iajoiner committed Oct 29, 2024
1 parent 8d15c52 commit 6f4a527
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 27 deletions.
27 changes: 2 additions & 25 deletions sdk/src/args.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{PostprocessingLevel, SxTClient};
use clap::{Parser, ValueEnum};
use clap::Parser;

/// Struct to define and parse command-line arguments for Proof of SQL Client.
///
Expand Down Expand Up @@ -88,30 +88,7 @@ pub struct SdkArgs {
value_enum,
help = "Level of postprocessing allowed, default is `Cheap`"
)]
pub postprocessing_level: PostprocessingLevelArg,
}

/// Level of postprocessing allowed.
///
/// We have it as a separate enum from `PostprocessingLevel` so that the core of the lib won't depend on `clap`.
#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)]
pub enum PostprocessingLevelArg {
/// No postprocessing allowed
None,
/// Only cheap postprocessing allowed
Cheap,
/// All postprocessing allowed
All,
}

impl From<PostprocessingLevelArg> for PostprocessingLevel {
fn from(arg: PostprocessingLevelArg) -> Self {
match arg {
PostprocessingLevelArg::None => PostprocessingLevel::None,
PostprocessingLevelArg::Cheap => PostprocessingLevel::Cheap,
PostprocessingLevelArg::All => PostprocessingLevel::All,
}
}
pub postprocessing_level: PostprocessingLevel,
}

impl From<&SdkArgs> for SxTClient {
Expand Down
3 changes: 2 additions & 1 deletion sdk/src/client.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{get_access_token, query_commitments};
use clap::ValueEnum;
use proof_of_sql::{
base::database::{OwnedTable, TableRef},
proof_primitive::dory::{
Expand All @@ -21,7 +22,7 @@ mod prover {
/// Level of postprocessing allowed
///
/// Some postprocessing steps are expensive so we allow the user to control the level of postprocessing.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)]
pub enum PostprocessingLevel {
/// No postprocessing allowed
None,
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mod args;
pub use args::{PostprocessingLevelArg, SdkArgs};
pub use args::SdkArgs;
mod auth;
pub use auth::get_access_token;
mod client;
Expand Down

0 comments on commit 6f4a527

Please sign in to comment.