From dc6e555eb8c412d74e8e93920b84f1d1acebb337 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sof=C3=ADa=20Celi?= Date: Wed, 22 May 2024 15:11:03 +0100 Subject: [PATCH] Flags (#1) * From env * To env * Other notif * For all dirs * Dirs * Nicer readme * Docs * Fix * Other flag * Avoid ignoring tests * Nits * Nits 2 --- Cargo.toml | 3 ++ Makefile | 61 ++++++++++++++++----- README.md | 106 ++++++++++++++++++++++++++++++++++--- benches/bench.rs | 39 ++++++++------ pi-rs-cli-utils/src/lib.rs | 16 +++++- src/api.rs | 9 ++-- 6 files changed, 190 insertions(+), 44 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e383d76..c4edae9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,3 +30,6 @@ pi-rs-cli-utils = {path = "./pi-rs-cli-utils"} [[bench]] name = "bench" harness = false + +[lib] +bench = false diff --git a/Makefile b/Makefile index 0f66b03..ddb60d2 100644 --- a/Makefile +++ b/Makefile @@ -8,9 +8,11 @@ PREVIOUS_DIR=.. # these are the FrodoPIR parameters to be used for benchmarking NUMBER_OF_ELEMENTS_EXP=16 LWE_DIMENSION=1774 # as per FrodoPIR paper -ELEMENT_SIZE_BITS=13 +ELEMENT_SIZE_BITS=8192 # 2**13 PLAINTEXT_SIZE_EXP=10 NUM_SHARDS=8 +DB=true +KV=true # rust flags RUST_BACKTRACE=1 @@ -24,8 +26,8 @@ DB_ENV=DB_FILE=${PREVIOUS_DIR}/${DB_FILE_PATH} PARAMS_OUTPUT_PATH=${PREVIOUS_DIR DB_GEN_PRELIM=DB_ALL_ONES=${DB_ALL_ONES} DB_NUM_ENTRIES_EXP=${DB_NUM_ENTRIES_EXP} DB_OUTPUT_PATH=${DB_FILE_PATH} DB_ELEMENT_SIZE_BITS=${ELEMENT_SIZE_BITS} PRELIM=${RUST_FLAGS} -PIR_FLAGS=-m ${NUMBER_OF_ELEMENTS_EXP} --dim ${LWE_DIMENSION} --ele_size ${ELEMENT_SIZE_BITS} --plaintext_bits ${PLAINTEXT_SIZE_EXP} --num_shards ${NUM_SHARDS} -PIR_ENV=PIR_NUMBER_OF_ELEMENTS_EXP=${NUMBER_OF_ELEMENTS_EXP} PIR_LWE_DIM=${LWE_DIMENSION} PIR_ELEM_SIZE_BITS=${ELEMENT_SIZE_BITS} PIR_PLAINTEXT_BITS=${PLAINTEXT_SIZE_EXP} PIR_NUM_SHARDS=${NUM_SHARDS} +PIR_FLAGS=-m ${NUMBER_OF_ELEMENTS_EXP} --dim ${LWE_DIMENSION} --ele_size ${ELEMENT_SIZE_BITS} --plaintext_bits ${PLAINTEXT_SIZE_EXP} --num_shards ${NUM_SHARDS} -offline ${DB} +PIR_ENV=PIR_NUMBER_OF_ELEMENTS_EXP=${NUMBER_OF_ELEMENTS_EXP} PIR_LWE_DIM=${LWE_DIMENSION} PIR_ELEM_SIZE_BITS=${ELEMENT_SIZE_BITS} PIR_PLAINTEXT_BITS=${PLAINTEXT_SIZE_EXP} PIR_NUM_SHARDS=${NUM_SHARDS} BENCH_DB_GEN=${DB} BENCH_KV=${KV} PIR_ENV_ALL=PIR_LWE_DIM=${LWE_DIMENSION} PIR_NUM_SHARDS=${NUM_SHARDS} LIB_PRELIM=${DB_FILE_PRELIM} @@ -54,14 +56,45 @@ docs: bench: ${PRELIM} ${PIR_ENV} ${CARGO} bench -bench-standard: - ${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=8192 PIR_NUMBER_OF_ELEMENTS_EXP=16 PIR_PLAINTEXT_BITS=10 ${CARGO} bench > benchmarks-16-1kb.txt - ${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=8192 PIR_NUMBER_OF_ELEMENTS_EXP=17 PIR_PLAINTEXT_BITS=10 ${CARGO} bench > benchmarks-17-1kb.txt - ${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=8192 PIR_NUMBER_OF_ELEMENTS_EXP=18 PIR_PLAINTEXT_BITS=10 ${CARGO} bench > benchmarks-18-1kb.txt - ${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=8192 PIR_NUMBER_OF_ELEMENTS_EXP=19 PIR_PLAINTEXT_BITS=9 ${CARGO} bench > benchmarks-19-1kb.txt - ${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=8192 PIR_NUMBER_OF_ELEMENTS_EXP=20 PIR_PLAINTEXT_BITS=9 ${CARGO} bench > benchmarks-20-1kb.txt - -bench-keyword: - ${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=819200 PIR_NUMBER_OF_ELEMENTS_EXP=14 PIR_PLAINTEXT_BITS=10 ${CARGO} bench > benchmarks-14-kw.txt - ${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=245760 PIR_NUMBER_OF_ELEMENTS_EXP=17 PIR_PLAINTEXT_BITS=10 ${CARGO} bench > benchmarks-17-kw.txt - ${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=2048 PIR_NUMBER_OF_ELEMENTS_EXP=20 PIR_PLAINTEXT_BITS=9 ${CARGO} bench > benchmarks-20-kw.txt +bench-keyword-standard: + ${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=8192 PIR_NUMBER_OF_ELEMENTS_EXP=16 PIR_PLAINTEXT_BITS=10 BENCH_DB_GEN=true BENCH_KV=true ${CARGO} bench > benchmarks-16-1kb.txt + ${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=8192 PIR_NUMBER_OF_ELEMENTS_EXP=17 PIR_PLAINTEXT_BITS=10 BENCH_DB_GEN=true BENCH_KV=true ${CARGO} bench > benchmarks-17-1kb.txt + ${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=8192 PIR_NUMBER_OF_ELEMENTS_EXP=18 PIR_PLAINTEXT_BITS=10 BENCH_DB_GEN=true BENCH_KV=true ${CARGO} bench > benchmarks-18-1kb.txt + ${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=8192 PIR_NUMBER_OF_ELEMENTS_EXP=19 PIR_PLAINTEXT_BITS=9 BENCH_DB_GEN=true BENCH_KV=true ${CARGO} bench > benchmarks-19-1kb.txt + ${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=8192 PIR_NUMBER_OF_ELEMENTS_EXP=20 PIR_PLAINTEXT_BITS=9 BENCH_DB_GEN=true BENCH_KV=true ${CARGO} bench > benchmarks-20-1kb.txt + +bench-keyword-all: + ${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=819200 PIR_NUMBER_OF_ELEMENTS_EXP=14 PIR_PLAINTEXT_BITS=10 BENCH_DB_GEN=true BENCH_KV=true ${CARGO} bench > benchmarks-14-kw.txt + ${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=245760 PIR_NUMBER_OF_ELEMENTS_EXP=17 PIR_PLAINTEXT_BITS=10 BENCH_DB_GEN=true BENCH_KV=true ${CARGO} bench > benchmarks-17-kw.txt + ${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=2048 PIR_NUMBER_OF_ELEMENTS_EXP=20 PIR_PLAINTEXT_BITS=9 BENCH_DB_GEN=true BENCH_KV=true ${CARGO} bench > benchmarks-20-kw.txt + +bench-keyword-20: + ${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=2048 PIR_NUMBER_OF_ELEMENTS_EXP=20 PIR_PLAINTEXT_BITS=9 BENCH_DB_GEN=false BENCH_KV=true ${CARGO} bench > benchmarks-20-kw.txt + +bench-keyword-17: + ${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=245760 PIR_NUMBER_OF_ELEMENTS_EXP=17 PIR_PLAINTEXT_BITS=10 BENCH_DB_GEN=false BENCH_KV=true ${CARGO} bench > benchmarks-17-kw.txt + +bench-keyword-14: + ${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=819200 PIR_NUMBER_OF_ELEMENTS_EXP=14 PIR_PLAINTEXT_BITS=10 BENCH_DB_GEN=false BENCH_KV=true ${CARGO} bench > benchmarks-14-kw.txt + +bench-index-standard: + ${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=8192 PIR_NUMBER_OF_ELEMENTS_EXP=16 PIR_PLAINTEXT_BITS=10 BENCH_DB_GEN=true BENCH_KV=false ${CARGO} bench > benchmarks-i-16-1kb.txt + ${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=8192 PIR_NUMBER_OF_ELEMENTS_EXP=17 PIR_PLAINTEXT_BITS=10 BENCH_DB_GEN=true BENCH_KV=false ${CARGO} bench > benchmarks-i-17-1kb.txt + ${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=8192 PIR_NUMBER_OF_ELEMENTS_EXP=18 PIR_PLAINTEXT_BITS=10 BENCH_DB_GEN=true BENCH_KV=false ${CARGO} bench > benchmarks-i-18-1kb.txt + ${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=8192 PIR_NUMBER_OF_ELEMENTS_EXP=19 PIR_PLAINTEXT_BITS=9 BENCH_DB_GEN=true BENCH_KV=false ${CARGO} bench > benchmarks-19-i-1kb.txt + ${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=8192 PIR_NUMBER_OF_ELEMENTS_EXP=20 PIR_PLAINTEXT_BITS=9 BENCH_DB_GEN=true BENCH_KV=false ${CARGO} bench > benchmarks-20-i-1kb.txt + +bench-index-all: + ${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=819200 PIR_NUMBER_OF_ELEMENTS_EXP=14 PIR_PLAINTEXT_BITS=10 BENCH_DB_GEN=true BENCH_KV=false ${CARGO} bench > benchmarks-14-i.txt + ${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=245760 PIR_NUMBER_OF_ELEMENTS_EXP=17 PIR_PLAINTEXT_BITS=10 BENCH_DB_GEN=true BENCH_KV=false ${CARGO} bench > benchmarks-17-i.txt + ${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=2048 PIR_NUMBER_OF_ELEMENTS_EXP=20 PIR_PLAINTEXT_BITS=9 BENCH_DB_GEN=true BENCH_KV=false ${CARGO} bench > benchmarks-20-i.txt + +bench-index-20: + ${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=2048 PIR_NUMBER_OF_ELEMENTS_EXP=20 PIR_PLAINTEXT_BITS=9 BENCH_DB_GEN=false BENCH_KV=false ${CARGO} bench > benchmarks-20-kw.txt + +bench-index-17: + ${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=245760 PIR_NUMBER_OF_ELEMENTS_EXP=17 PIR_PLAINTEXT_BITS=10 BENCH_DB_GEN=false BENCH_KV=false ${CARGO} bench > benchmarks-17-kw.txt + +bench-index-14: + ${PRELIM} ${PIR_ENV_ALL} PIR_ELEM_SIZE_BITS=819200 PIR_NUMBER_OF_ELEMENTS_EXP=14 PIR_PLAINTEXT_BITS=10 BENCH_DB_GEN=false BENCH_KV=false ${CARGO} bench > benchmarks-14-kw.txt + diff --git a/README.md b/README.md index 189ed23..9cb481a 100644 --- a/README.md +++ b/README.md @@ -18,10 +18,11 @@ In order to natively build, run, test and benchmark the library, you will need t Python3 >= 3.9.7 ``` -To obtain our performance numbers as reported in our paper, we run our benchmarks in AWS EC2 ``t2.t2xlarge`` and ``c5.9xlarge`` machines. - Note that we internally use the [xorf](https://github.com/ayazhafiz/xorf) library, but we modify it as seen [here](https://github.com/claucece/chalamet/tree/main/bff-modp). +To obtain our performance numbers as reported in Table 2 of our paper, we run our benchmarks in AWS EC2 ``t2.t2xlarge`` and ``c5.9xlarge`` machines, as reported. + + ## Quickstart ### Local @@ -65,7 +66,25 @@ To view documentation (in a web browser manner): #### Benchmarking -To run a specific set of benchmarks, run (note the this process is slow. On average, it takes 12 minutes): +There are several parameters that you can pass as flag to the `cargo bench` command, so that you can test the scheme. +These are (with their default values): + +``` +NUMBER_OF_ELEMENTS_EXP=16 (the m value of a DB: the number of rows) +LWE_DIMENSION=1774 (The LWE dimension) +ELEMENT_SIZE_BITS=8192 # 2**13 (the size of each element in bits) +PLAINTEXT_SIZE_EXP=10 (the size of each plaintext element: determines w of a DB: the size of the rows) +NUM_SHARDS=8 +DB=true (if the offline steps will be bechmarked: these steps are very slow) +KV=true (if you want to execute the keyword-based PIR or else the index-based) + +``` + +These can also be found on the Makefile (lines 9-14). + +--- + +To run a simple benchmark (for a DB of 2^16 x 1024B) with offline steps, run (note the this process is slow. On average, it takes 12 minutes): ``` make bench @@ -73,23 +92,57 @@ To run a specific set of benchmarks, run (note the this process is slow. On aver This command will execute client query benchmarks and Database generation benchmarks (for more details, see the `benches/bench.rs` file). -To run all benchmarks (note that this process is very slow, it takes around 30 minutes): +--- +To run all benchmarks as reported in lines 1-10 of Table 2 of our paper (note that this process is very slow, it takes around 30 minutes): ``` - make bench-standard + make bench-keyword-standard ``` This command will execute client query benchmarks and Database generation benchmarks for 16, 17, 18, 19 and 20 Number of DB items (log(m)). The results of these benchmarks can be found on Table 2 of our paper. In order to see the results of the benchmarks, navigate to the `benchmarks-x-x.txt` file. -You can also run: +--- +To run all benchmarks as reported in lines 11-13 of Table 2 of our paper and of Table 3 (note that this process is significantly slow): + +``` + make bench-keyword-all +``` + +In order to see the results of the benchmarks, navigate to the `benchmarks-x-x.txt` file. + +In order to make the results of lines 11-13 of Table 2 of our paper and of Table 3 of our paper easier to reproduce, we have made available these three commands: + + +``` + make bench-keyword-20 + make bench-keyword-14 + make bench-keyword-17 +``` + +which omit any offline steps, and can be run independently for 2^20 x 256B, 2^17 x 30kB and 2^14 x 100kB. + +--- + +In order to run the benchmarks for Table 4 (index-based PIR with FrodoPIR), one can run: ``` - make bench-keyword + make bench-index-standard #For lines 1-10 + make bench-index-all #For lines 11-13 ``` -to reproduce the results of Table 3 of our paper. +Note that those directions take a long time as they execute the offline steps as well. + +One can run the following to omit the offline steps: + +``` + make bench-index-20 + make bench-index-14 + make bench-index-17 +``` + +--- If all benches build and run correctly, you should see an `Finished ... benchmarks` under them. We use [Criterion](https://bheisler.github.io/criterion.rs/book/index.html) for benchmarking. @@ -97,6 +150,43 @@ If you want to see and have explanations of the benchmarks, you can locally open **Note**: When running the benches, a warning might appear ``Warning: Unable to complete 10 samples in 100.0s. You may wish to increase target time to 486.6s.``. If you want to silence the warning, you can change line 30 of `benches/bech.rs` file to 500 or more. Note that this will make the running of benches slower. +In order to interpret the `benchmarks-x-x.txt` files, we provide some guidance here: + + +First, we have the initial lines describing the parameters for the benchmark. + +``` +[KV] Starting benches for keyword PIR. +[KV] Setting up DB for benchmarking. This might take a while... +[KV] The params are: m: 65536, lwe_dim: 1774, elem_size: 8192, plaintext-bits: 10 +[KV] Are we benchmarking offline steps? true +``` + +These simply describe the LWE parameters for running the PIR interaction, note that the [KV] part here shows that we are running the keyword PIR benchmarks. This part can take a while, as the database and the public parameters are being generated for the interaction. It also states if we are running any offline steps, which can be omitted as they are significantly slow. + +Once this setup has completed, we see the following. + +``` +[KV] Setup complete, starting benchmarks... +[KV] Filter Params: segment-len: 2048, segment-len-mask: 2047, segment-count-len: 73728 +[KV] Starting client query benchmarks +``` + +This describes the individual filter parameters for the filters being used, and informs us that the benchmarks will now be computed for each piece of functionality. + +Each individual benchmark is then displayed in the following way. + +``` +Benchmarking lwe/[KV] server response, lwe_dim: 1774, matrix_height: 77824, omega: 820: Collecting 100 samples in estimated 5.2698 s (300 iterations) +Benchmarking lwe/[KV] server response, lwe_dim: 1774, matrix_height: 77824, omega: 820: Analyzing +lwe/[KV] server response, lwe_dim: 1774, matrix_height: 77824, omega: 820 + time: [17.566 ms 17.670 ms 17.789 ms] +``` + +The middle time here is the average taken over the number of samples displayed. The name of the benchmark in this case is "server response", which took 17.67ms, and this is the value that we used in the paper. + +In terms of Table 2, the key benchmarks are "create client query prepare" (Query), "server response" (Response), and "client parse server response" (Parsing), as these are the main online operations in the protocol. + ### Tests We have two big tests that the library executes: diff --git a/benches/bench.rs b/benches/bench.rs index 83015e5..09d1b98 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -10,8 +10,6 @@ use std::time::Duration; use keyword_pir_lwe::db::FilterParams; const BENCH_KV: bool = true; -const BENCH_ONLINE: bool = true; -const BENCH_DB_GEN: bool = true; fn criterion_benchmark(c: &mut Criterion) { let CLIFlags { @@ -19,13 +17,17 @@ fn criterion_benchmark(c: &mut Criterion) { lwe_dim, elem_size, plaintext_bits, + offline, + keyword, .. } = parse_from_env(); let mut lwe_group = c.benchmark_group("lwe"); - if BENCH_KV { + if keyword { + println!("[KV] Starting benches for keyword PIR."); println!("[KV] Setting up DB for benchmarking. This might take a while..."); println!("[KV] The params are: m: {}, lwe_dim: {}, elem_size: {}, plaintext-bits: {}", m, lwe_dim, elem_size, plaintext_bits); + println!("[KV] Are we benchmarking offline steps? {}", offline); let kv_db_eles = bench_utils::generate_kv_db_elems(m, (elem_size + 7) / 8); let keys: Vec = kv_db_eles.iter().map(|e| e.0.clone()).collect(); @@ -41,22 +43,23 @@ fn criterion_benchmark(c: &mut Criterion) { .unwrap(); println!("[KV] Setup complete, starting benchmarks..."); - if BENCH_ONLINE { - _bench_client_kv_query( - &mut lwe_group, - &shard, - (keys[0].clone(), values[0].clone()), - ); - } + println!("[KV] Benchmarking online steps..."); + _bench_client_kv_query( + &mut lwe_group, + &shard, + (keys[0].clone(), values[0].clone()), + ); - if BENCH_DB_GEN { + if offline { + println!("[KV] Benchmarking offline steps..."); lwe_group.sample_size(10); lwe_group.measurement_time(Duration::from_secs(100)); // To remove a warning, you can increase this to 500 or more. _bench_kv_db_generation(&mut lwe_group, &shard, &keys, &values); } } else { + println!("[I] Starting benches for index PIR."); let db_eles = bench_utils::generate_db_eles(m, (elem_size + 7) / 8); - println!("Setting up DB for benchmarking. This might take a while..."); + println!("[I] Setting up DB for benchmarking. This might take a while..."); let shard = Shard::from_base64_strings( &db_eles, lwe_dim, @@ -65,11 +68,13 @@ fn criterion_benchmark(c: &mut Criterion) { plaintext_bits, ) .unwrap(); - println!("Setup complete, starting benchmarks"); - if BENCH_ONLINE { - _bench_client_query(&mut lwe_group, &shard); - } - if BENCH_DB_GEN { + println!("[I] Setup complete, starting benchmarks"); + + println!("[I] Benchmarking online steps..."); + _bench_client_query(&mut lwe_group, &shard); + + if offline { + println!("[I] Benchmarking offline steps..."); lwe_group.sample_size(10); lwe_group.measurement_time(Duration::from_secs(100)); // To remove a warning, you can increase this to 500 or more. _bench_db_generation(&mut lwe_group, &shard, &db_eles); diff --git a/pi-rs-cli-utils/src/lib.rs b/pi-rs-cli-utils/src/lib.rs index 71a69aa..8ac37cc 100644 --- a/pi-rs-cli-utils/src/lib.rs +++ b/pi-rs-cli-utils/src/lib.rs @@ -6,6 +6,8 @@ pub struct CLIFlags { pub lwe_dim: usize, pub plaintext_bits: usize, pub elem_size: usize, + pub offline: bool, + pub keyword: bool, } pub fn parse_cli_flags() -> CLIFlags { @@ -64,20 +66,27 @@ pub fn parse_cli_flags() -> CLIFlags { lwe_dim, plaintext_bits, elem_size, + offline: true, + keyword: true, } } pub fn parse_from_env() -> CLIFlags { - let elem_size: usize = env::var("PIR_ELEM_SIZE_BITS").unwrap().parse().unwrap(); + let elem_size: usize = + env::var("PIR_ELEM_SIZE_BITS").unwrap().parse().unwrap(); let lwe_dim: usize = env::var("PIR_LWE_DIM").unwrap().parse().unwrap(); let plaintext_bits: usize = env::var("PIR_PLAINTEXT_BITS").unwrap().parse().unwrap(); let m = parse_exp_to_usize(env::var("PIR_NUMBER_OF_ELEMENTS_EXP").unwrap()); + let offline = parse_val_to_bool(env::var("BENCH_DB_GEN").unwrap()); + let keyword = parse_val_to_bool(env::var("BENCH_KV").unwrap()); CLIFlags { m, lwe_dim, plaintext_bits, elem_size, + offline, + keyword, } } @@ -86,3 +95,8 @@ pub fn parse_exp_to_usize(v: String) -> usize { let res = 2_u32.pow(exp) as usize; res } + +pub fn parse_val_to_bool(v: String) -> bool { + let res: bool = v.parse().unwrap(); + res +} diff --git a/src/api.rs b/src/api.rs index c72af5c..4fc5465 100644 --- a/src/api.rs +++ b/src/api.rs @@ -66,8 +66,8 @@ impl Shard { Ok(()) } - // Produces a serialized response (base64-encoded) to a serialized - // client query + /// Produces a serialized response (base64-encoded) to a serialized + /// client query pub fn respond(&self, q: &Query) -> ResultBoxedError> { let q = q.as_slice(); let resp = Response( @@ -98,6 +98,7 @@ impl Shard { } } +/// EncodeKV represents an encoded key-value struct. #[derive(Clone, Debug, Serialize, Deserialize)] pub struct EncodedKV { key: String, @@ -212,8 +213,8 @@ impl KVShard { Ok(()) } - // Produces a serialized response (base64-encoded) to a serialized - // client query + /// Produces a serialized response (base64-encoded) to a serialized + /// client query pub fn respond(&self, q: &Query) -> ResultBoxedError> { let resp = Response( (0..self.db.get_row_width_self())