diff --git a/README.md b/README.md index 097b83e..dfb3503 100644 --- a/README.md +++ b/README.md @@ -139,7 +139,7 @@ If the predefined JSON types are not sufficient for your use case, you can defin The JSON struct in `dep::json_parser::json::JSON` is parametrised with the following parameters: -`struct JSON` +`struct JSON` - `NumBytes` : the maximum size of the initial json blob - `NumPackedFields` : take `NumBytes / 31`, round up to the nearest integer, then add 3! diff --git a/src/_comparison_tools/bounds_checker.nr b/src/_comparison_tools/bounds_checker.nr index 01266bc..6bec991 100644 --- a/src/_comparison_tools/bounds_checker.nr +++ b/src/_comparison_tools/bounds_checker.nr @@ -27,14 +27,14 @@ in this case, i == M * @description this method is cheaper than querying `i < boundary` for `u16` and `u32` types * cost = 3 gates + 2 gates per iteration **/ -pub fn get_validity_flags(boundary: u16) -> [Field; N] { +pub fn get_validity_flags(boundary: u32) -> [Field; N] { let flags: [Field; N] = __get_validity_flags(boundary); get_validity_flags_inner(boundary, flags) } -unconstrained fn __get_validity_flags(boundary: u16) -> [Field; N] { +unconstrained fn __get_validity_flags(boundary: u32) -> [Field; N] { let mut result: [Field; N] = [0; N]; - for i in 0..N as u16 { + for i in 0..N { if i < boundary { result[i] = 1; } @@ -55,7 +55,7 @@ unconstrained fn __get_validity_flags(boundary: u16) -> [Field; N] { * aligns with what is expected from testing `i < boundary` * N.B. this method will revert if `boundary > N` **/ -fn get_validity_flags_inner(boundary: u16, flags: [Field; N]) -> [Field; N] { +fn get_validity_flags_inner(boundary: u32, flags: [Field; N]) -> [Field; N] { let initial_flag = flags[0]; let final_flag = flags[N - 1]; diff --git a/src/_string_tools/slice_packed_field.nr b/src/_string_tools/slice_packed_field.nr index 688bb6a..a8d749e 100644 --- a/src/_string_tools/slice_packed_field.nr +++ b/src/_string_tools/slice_packed_field.nr @@ -441,8 +441,8 @@ unconstrained fn __slice_field(f: Field, num_bytes: Field) -> [Field; 5] { } unconstrained fn __divmod(numerator: Field, denominator: Field) -> (Field, Field) { - let quotient = numerator as u16 / denominator as u16; - let remainder = numerator as u16 % denominator as u16; + let quotient = numerator as u32 / denominator as u32; + let remainder = numerator as u32 % denominator as u32; (quotient as Field, remainder as Field) } @@ -473,7 +473,7 @@ fn divmod_31(numerator: Field) -> (Field, Field) { unconstrained fn decompose(val: Field) -> [Field; 16] { let mut r: [Field; 16] = [0; 16]; - let mut it = val as u16; + let mut it = val as u32; for i in 0..16 { r[i] = (it & 1) as Field; it >>= 1; @@ -482,7 +482,7 @@ unconstrained fn decompose(val: Field) -> [Field; 16] { } // 5 gates? -pub fn get_last_limb_path(last_limb_index: Field) -> [Field; OutputFields] { +pub fn get_last_limb_path(last_limb_index: Field) -> [Field; OutputFields] { // TODO we offset by 1 explain why (0 byte length produces 0 - 1 which = invalid array index. we just add 1 and increase array length by 1 to compensate) let path = LAST_LIMB_PATH[last_limb_index + 1]; // 2 @@ -550,7 +550,7 @@ pub fn slice_field(f: Field, num_bytes: Field) -> (Field, Field) { * @brief Given an array of fields that pack 31 bytes, return an array that slices the packed byte array at a given index for a given number of bytes * @description Some serious dark black magic nonsense going on here. TODO: document **/ -pub fn slice_fields( +pub fn slice_fields( data: [Field; InputFields], start_byte: Field, num_bytes: Field diff --git a/src/_string_tools/string_chopper.nr b/src/_string_tools/string_chopper.nr index 58cdda7..22e6d68 100644 --- a/src/_string_tools/string_chopper.nr +++ b/src/_string_tools/string_chopper.nr @@ -1,9 +1,9 @@ use crate::_string_tools::slice_packed_field::slice_fields; -struct StringChopper {} +struct StringChopper {} -impl StringChopper { - fn slice_string( +impl StringChopper { + fn slice_string( _: Self, haystack: [Field; HaystackPackedFields], start_bytes: Field, diff --git a/src/_table_generation/make_tables.nr b/src/_table_generation/make_tables.nr index 2066750..2302f90 100644 --- a/src/_table_generation/make_tables.nr +++ b/src/_table_generation/make_tables.nr @@ -341,12 +341,12 @@ unconstrained fn make_token_validation_table() -> [Field; NUM_TOKENS * NUM_TOKEN single_value_layer_flags[KEY_TOKEN] = no_token_outcomes; let mut flattened_flags: [Field; NUM_TOKENS * NUM_TOKENS * 3] = [0; NUM_TOKENS * NUM_TOKENS * 3]; - let NN = NUM_TOKENS * NUM_TOKENS as Field; + let NN = (NUM_TOKENS * NUM_TOKENS) as Field; for j in 0..NUM_TOKENS as u32 { for k in 0..NUM_TOKENS as u32 { - flattened_flags[OBJECT_LAYER * NN + j as Field * NUM_TOKENS + k as Field] = object_layer_flags[j][k]; - flattened_flags[ARRAY_LAYER * NN + j as Field * NUM_TOKENS + k as Field] = array_layer_flags[j][k]; - flattened_flags[SINGLE_VALUE_LAYER * NN + j as Field * NUM_TOKENS + k as Field] = single_value_layer_flags[j][k]; + flattened_flags[OBJECT_LAYER * NN + j as Field * (NUM_TOKENS as Field) + k as Field] = object_layer_flags[j][k]; + flattened_flags[ARRAY_LAYER * NN + j as Field * (NUM_TOKENS as Field) + k as Field] = array_layer_flags[j][k]; + flattened_flags[SINGLE_VALUE_LAYER * NN + j as Field * (NUM_TOKENS as Field) + k as Field] = single_value_layer_flags[j][k]; } } flattened_flags @@ -541,17 +541,17 @@ unconstrained fn generate_token_flags_table() -> [Field; NUM_TOKENS * 2] { numeric_flags.new_context = ARRAY_LAYER; literal_flags.new_context = ARRAY_LAYER; - flags[NUM_TOKENS + NO_TOKEN] = no_token_flags; - flags[NUM_TOKENS + BEGIN_OBJECT_TOKEN] = begin_object_flags; - flags[NUM_TOKENS + END_OBJECT_TOKEN] = end_object_flags; - flags[NUM_TOKENS + BEGIN_ARRAY_TOKEN] = begin_array_flags; - flags[NUM_TOKENS + END_ARRAY_TOKEN] = end_array_flags; - flags[NUM_TOKENS + KEY_SEPARATOR_TOKEN] = no_token_flags; - flags[NUM_TOKENS + VALUE_SEPARATOR_TOKEN] = no_token_flags; - flags[NUM_TOKENS + STRING_TOKEN] = string_flags; - flags[NUM_TOKENS + NUMERIC_TOKEN] = numeric_flags; - flags[NUM_TOKENS + LITERAL_TOKEN] = literal_flags; - flags[NUM_TOKENS + KEY_TOKEN] = key_token_flags; + flags[NUM_TOKENS + (NO_TOKEN as u32)] = no_token_flags; + flags[NUM_TOKENS + (BEGIN_OBJECT_TOKEN as u32)] = begin_object_flags; + flags[NUM_TOKENS + (END_OBJECT_TOKEN as u32)] = end_object_flags; + flags[NUM_TOKENS + (BEGIN_ARRAY_TOKEN as u32)] = begin_array_flags; + flags[NUM_TOKENS + (END_ARRAY_TOKEN as u32)] = end_array_flags; + flags[NUM_TOKENS + (KEY_SEPARATOR_TOKEN as u32)] = no_token_flags; + flags[NUM_TOKENS + (VALUE_SEPARATOR_TOKEN as u32)] = no_token_flags; + flags[NUM_TOKENS + (STRING_TOKEN as u32)] = string_flags; + flags[NUM_TOKENS + (NUMERIC_TOKEN as u32)] = numeric_flags; + flags[NUM_TOKENS + (LITERAL_TOKEN as u32)] = literal_flags; + flags[NUM_TOKENS + (KEY_TOKEN as u32)] = key_token_flags; let mut result: [Field; NUM_TOKENS * 2] = [0; NUM_TOKENS * 2]; for i in 0..(NUM_TOKENS as u32 * 2) { diff --git a/src/get_array.nr b/src/get_array.nr index d520d86..594298f 100644 --- a/src/get_array.nr +++ b/src/get_array.nr @@ -8,7 +8,7 @@ use crate::getters::JSONValue; /** * @brief getter methods for extracting array types out of a JSON struct **/ -impl JSON { +impl JSON { /** * @brief if the root JSON is an array, return its length @@ -23,7 +23,7 @@ impl where, if the array exists, the JSON object will have the requested array as its root value **/ - fn get_array(self, key: [u8; KeyBytes]) -> Option { + fn get_array(self, key: [u8; KeyBytes]) -> Option { assert(self.layer_type_of_root != ARRAY_LAYER, "cannot extract array elements via a key"); let (exists, key_index) = self.key_exists_impl(key); let entry: JSONEntry = self.json_entries_packed[key_index].into(); @@ -44,7 +44,7 @@ impl(self, key: [u8; KeyBytes]) -> Self { + fn get_array_unchecked(self, key: [u8; KeyBytes]) -> Self { assert(self.layer_type_of_root != ARRAY_LAYER, "cannot extract array elements via a key"); let (entry, key_index) = self.get_json_entry_unchecked_with_key_index(key); @@ -62,7 +62,7 @@ impl(self, key: BoundedVec) -> Option { + fn get_array_var(self, key: BoundedVec) -> Option { assert(self.layer_type_of_root != ARRAY_LAYER, "cannot extract array elements via a key"); let (exists, key_index) = self.key_exists_impl_var(key); let entry: JSONEntry = self.json_entries_packed[key_index].into(); @@ -83,7 +83,7 @@ impl(self, key: BoundedVec) -> Self { + fn get_array_unchecked_var(self, key: BoundedVec) -> Self { assert(self.layer_type_of_root != ARRAY_LAYER, "cannot extract array elements via a key"); let (entry, key_index) = self.get_json_entry_unchecked_with_key_index_var(key); diff --git a/src/get_literal.nr b/src/get_literal.nr index c8d5a56..c8cb385 100644 --- a/src/get_literal.nr +++ b/src/get_literal.nr @@ -65,13 +65,13 @@ fn extract_literal_from_array( /** * @brief getter methods for extracting literal values out of a JSON struct **/ -impl JSON { +impl JSON { /** * @brief if the root JSON is an object, extract a literal value given by `key` * @description returns an Option which will be null if the literal does not exist **/ - fn get_literal(self, key: [u8; KeyBytes]) -> Option { + fn get_literal(self, key: [u8; KeyBytes]) -> Option { assert(self.layer_type_of_root != ARRAY_LAYER, "cannot extract array elements via a key"); let (exists, entry) = self.get_json_entry(key); @@ -87,7 +87,7 @@ impl(self, key: [u8; KeyBytes]) -> JSONLiteral { + fn get_literal_unchecked(self, key: [u8; KeyBytes]) -> JSONLiteral { assert(self.layer_type_of_root != ARRAY_LAYER, "cannot extract array elements via a key"); let entry= self.get_json_entry_unchecked(key); @@ -102,7 +102,7 @@ impl(self, key: BoundedVec) -> Option { + fn get_literal_var(self, key: BoundedVec) -> Option { assert(self.layer_type_of_root != ARRAY_LAYER, "cannot extract array elements via a key"); let (exists, entry) = self.get_json_entry_var(key); @@ -117,7 +117,7 @@ impl(self, key: BoundedVec) -> JSONLiteral { + fn get_literal_unchecked_var(self, key: BoundedVec) -> JSONLiteral { assert(self.layer_type_of_root != ARRAY_LAYER, "cannot extract array elements via a key"); let entry= self.get_json_entry_unchecked_var(key); diff --git a/src/get_number.nr b/src/get_number.nr index 9ab2795..b016741 100644 --- a/src/get_number.nr +++ b/src/get_number.nr @@ -28,13 +28,13 @@ fn extract_number_from_array(arr: [u8; U64_LENGTH_AS_BASE10_STRING], json_length * @note numeric values must fit into a `u64` type. * decimal values and scientific notation are not yet supported **/ -impl JSON { +impl JSON { /** * @brief if the root JSON is an object, extract a numeric value given by `key` * @description returns an Option which will be null if the key does not exist **/ - fn get_number(self, key: [u8; KeyBytes]) -> Option { + fn get_number(self, key: [u8; KeyBytes]) -> Option { let (exists, entry) = self.get_json_entry(key); assert( (entry.entry_type - NUMERIC_TOKEN) * exists as Field == 0, "get_number: entry exists but is not a number!" @@ -48,7 +48,7 @@ impl(self, key: [u8; KeyBytes]) -> u64 { + fn get_number_unchecked(self, key: [u8; KeyBytes]) -> u64 { let entry = self.get_json_entry_unchecked(key); assert(entry.entry_type == NUMERIC_TOKEN, "get_number_unchecked: entry exists but is not a number!"); let mut parsed_string: [u8; U64_LENGTH_AS_BASE10_STRING] = self.extract_string_entry(entry); @@ -59,7 +59,7 @@ impl(self, key: BoundedVec) -> Option { + fn get_number_var(self, key: BoundedVec) -> Option { let (exists, entry) = self.get_json_entry_var(key); assert( (entry.entry_type - NUMERIC_TOKEN) * exists as Field == 0, "get_number: entry exists but is not a number!" @@ -72,7 +72,7 @@ impl(self, key: BoundedVec) -> u64 { + fn get_number_unchecked_var(self, key: BoundedVec) -> u64 { let entry = self.get_json_entry_unchecked_var(key); assert(entry.entry_type == NUMERIC_TOKEN, "get_number_unchecked: entry exists but is not a number!"); let mut parsed_string: [u8; U64_LENGTH_AS_BASE10_STRING] = self.extract_string_entry(entry); diff --git a/src/get_object.nr b/src/get_object.nr index 94f0cc9..1ed5356 100644 --- a/src/get_object.nr +++ b/src/get_object.nr @@ -8,13 +8,13 @@ use crate::getters::JSONValue; /** * @brief getter methods for extracting object types out of a JSON struct **/ -impl JSON { +impl JSON { /** * @brief if the root JSON is an object, extract a child object given by `key` * @description returns an Option where, if the object exists, the JSON object will have the requested object as its root value **/ - fn get_object(self, key: [u8; KeyBytes]) -> Option { + fn get_object(self, key: [u8; KeyBytes]) -> Option { assert(self.layer_type_of_root != ARRAY_LAYER, "cannot extract array elements via a key"); let (exists, key_index) = self.key_exists_impl(key); @@ -35,7 +35,7 @@ impl(self, key: [u8; KeyBytes]) -> Self { + fn get_object_unchecked(self, key: [u8; KeyBytes]) -> Self { assert(self.layer_type_of_root != ARRAY_LAYER, "cannot extract array elements via a key"); let (entry, key_index) = self.get_json_entry_unchecked_with_key_index(key); let entry: JSONEntry = self.json_entries_packed[key_index].into(); @@ -52,7 +52,7 @@ impl(self, key: BoundedVec) -> Option { + fn get_object_var(self, key: BoundedVec) -> Option { assert(self.layer_type_of_root != ARRAY_LAYER, "cannot extract array elements via a key"); let (exists, key_index) = self.key_exists_impl_var(key); @@ -72,7 +72,7 @@ impl(self, key: BoundedVec) -> Self { + fn get_object_unchecked_var(self, key: BoundedVec) -> Self { assert(self.layer_type_of_root != ARRAY_LAYER, "cannot extract array elements via a key"); let (entry, key_index) = self.get_json_entry_unchecked_with_key_index_var(key); let entry: JSONEntry = self.json_entries_packed[key_index].into(); diff --git a/src/get_string.nr b/src/get_string.nr index f7ad727..8550103 100644 --- a/src/get_string.nr +++ b/src/get_string.nr @@ -9,7 +9,7 @@ use crate::enums::Layer::{OBJECT_LAYER, ARRAY_LAYER}; unconstrained fn to_u8(f: Field) -> u8 { f as u8 } -fn process_escape_sequences(input: BoundedVec) -> BoundedVec { +fn process_escape_sequences(input: BoundedVec) -> BoundedVec { let string = input.storage; let mut result: [u8; N] = [0; N]; let mut result_ptr = 0; @@ -85,14 +85,14 @@ fn test_process_escape_sequence() { * @note returned strings will have escape sequences converted into the relevant ASCII characters. * If you want to avoid this, use `get_value` instead of `get_string` **/ -impl JSON { +impl JSON { /** * @brief if the root JSON is an object, extract a string given by `key` * @description returns an Option which will be null if the key does not exist * @note the `StringBytes` parameter defines the maximum allowable length of the returned string **/ - fn get_string(self, key: [u8; KeyBytes]) -> Option> { + fn get_string(self, key: [u8; KeyBytes]) -> Option> { let (exists, entry) = self.get_json_entry(key); assert( (entry.entry_type - STRING_TOKEN) * exists as Field == 0, "get_string: entry exists but is not a string!" @@ -108,7 +108,7 @@ impl(self, key: [u8; KeyBytes]) -> BoundedVec { + fn get_string_unchecked(self, key: [u8; KeyBytes]) -> BoundedVec { let entry = self.get_json_entry_unchecked(key); assert(entry.entry_type == STRING_TOKEN, "get_string_unchecked: entry exists but is not a string!"); let parsed_string = BoundedVec { storage: self.extract_string_entry(entry), len: entry.json_length as u32 }; @@ -118,7 +118,7 @@ impl(self, key: BoundedVec) -> Option> { + fn get_string_var(self, key: BoundedVec) -> Option> { let (exists, entry) = self.get_json_entry_var(key); assert( (entry.entry_type - STRING_TOKEN) * exists as Field == 0, "get_string: entry exists but is not a string!" @@ -131,7 +131,7 @@ impl(self, key: BoundedVec) -> BoundedVec { + fn get_string_unchecked_var(self, key: BoundedVec) -> BoundedVec { let entry = self.get_json_entry_unchecked_var(key); assert(entry.entry_type == STRING_TOKEN, "get_string_unchecked: entry exists but is not a string!"); let parsed_string = BoundedVec { storage: self.extract_string_entry(entry), len: entry.json_length as u32 }; @@ -142,7 +142,7 @@ impl which will be null if the string does not exist **/ - fn get_string_from_array(self, array_index: Field) -> Option> { + fn get_string_from_array(self, array_index: Field) -> Option> { assert(self.layer_type_of_root == ARRAY_LAYER, "can only acceess array elements from array"); let parent_entry : JSONEntry = self.json_entries_packed[self.root_index_in_transcript].into(); @@ -165,7 +165,7 @@ impl(self, array_index: Field) -> BoundedVec { + fn get_string_from_array_unchecked(self, array_index: Field) -> BoundedVec { assert(self.layer_type_of_root == ARRAY_LAYER, "can only acceess array elements from array"); let parent_entry : JSONEntry = self.json_entries_packed[self.root_index_in_transcript].into(); @@ -187,7 +187,7 @@ impl( + fn get_string_from_path( self, keys: [BoundedVec; PathDepth] ) -> Option> { @@ -210,7 +210,7 @@ impl which will be null if the key does not exist * @note the `StringBytes` parameter defines the maximum allowable length of the returned value **/ - fn get_value(self, key: [u8; KeyBytes]) -> Option> { + fn get_value(self, key: [u8; KeyBytes]) -> Option> { let (exists, entry) = self.get_json_entry(key); let mut parsed_string: [u8; StringBytes] = self.extract_string_entry(entry); @@ -223,7 +223,7 @@ impl(self, key: [u8; KeyBytes]) -> JSONValue { + fn get_value_unchecked(self, key: [u8; KeyBytes]) -> JSONValue { let entry = self.get_json_entry_unchecked(key); JSONValue { value: BoundedVec { len: entry.json_length as u32, storage: self.extract_string_entry(entry) }, @@ -234,7 +234,7 @@ impl(self, key: BoundedVec) -> Option> { + fn get_value_var(self, key: BoundedVec) -> Option> { let (exists, entry) = self.get_json_entry_var(key); let mut parsed_string: [u8; StringBytes] = self.extract_string_entry(entry); @@ -245,7 +245,7 @@ impl(self, key: BoundedVec) -> JSONValue { + fn get_value_unchecked_var(self, key: BoundedVec) -> JSONValue { let entry = self.get_json_entry_unchecked_var(key); JSONValue { value: BoundedVec { len: entry.json_length as u32, storage: self.extract_string_entry(entry) }, @@ -257,7 +257,7 @@ impl which will be null if the value does not exist **/ - fn get_value_from_array(self, array_index: Field) -> Option> { + fn get_value_from_array(self, array_index: Field) -> Option> { assert(self.layer_type_of_root == ARRAY_LAYER, "can only acceess array elements from array"); let parent_entry : JSONEntry = self.json_entries_packed[self.root_index_in_transcript].into(); @@ -285,7 +285,7 @@ impl(self, array_index: Field) -> JSONValue { + fn get_value_from_array_unchecked(self, array_index: Field) -> JSONValue { assert(self.layer_type_of_root == ARRAY_LAYER, "can only acceess array elements from array"); let parent_entry : JSONEntry = self.json_entries_packed[self.root_index_in_transcript].into(); @@ -310,7 +310,7 @@ impl( + fn get_value_from_path( self, keys: [BoundedVec; PathDepth] ) -> Option> { diff --git a/src/getters.nr b/src/getters.nr index b75392f..b0328f0 100644 --- a/src/getters.nr +++ b/src/getters.nr @@ -23,13 +23,13 @@ struct KeySearchResult { /** * @brief helper methods for extracting data out of a processed JSON object **/ -impl JSON { +impl JSON { /** * @brief If the root JSON is an object, extract a JSONEntry that describes an array, object or value that maps to a given key * @description returns an Option which will be null if the entry does not exist **/ - fn get_json_entry(self, key: [u8; KeyBytes]) -> (bool, JSONEntry) { + fn get_json_entry(self, key: [u8; KeyBytes]) -> (bool, JSONEntry) { // let key_index = self.find_key_in_map(keyhash); // assert(self.key_hashes[key_index] == keyhash); assert(self.layer_type_of_root != ARRAY_LAYER, "cannot extract array elements via a key"); @@ -43,7 +43,7 @@ impl(self, key: [u8; KeyBytes]) -> JSONEntry { + fn get_json_entry_unchecked(self, key: [u8; KeyBytes]) -> JSONEntry { assert(self.layer_type_of_root != ARRAY_LAYER, "cannot extract array elements via a key"); let hasher: ByteHasher = ByteHasher {}; @@ -63,7 +63,7 @@ impl( + fn get_json_entry_var( self, key: BoundedVec ) -> (bool, JSONEntry) { @@ -79,11 +79,11 @@ impl(self, key: BoundedVec) -> JSONEntry { + fn get_json_entry_unchecked_var(self, key: BoundedVec) -> JSONEntry { assert(self.layer_type_of_root != ARRAY_LAYER, "cannot extract array elements via a key"); let hasher: ByteHasher = ByteHasher {}; - let keyhash = hasher.get_keyhash_var(key.storage, 0, key.len as u16); + let keyhash = hasher.get_keyhash_var(key.storage, 0, key.len as u32); let two_pow_216 = 0x100000000000000000000000000000000000000000000000000000000; let keyhash = keyhash + self.root_id * two_pow_216; @@ -99,7 +99,7 @@ impl(self, key: [u8; KeyBytes]) -> (JSONEntry, Field) { + fn get_json_entry_unchecked_with_key_index(self, key: [u8; KeyBytes]) -> (JSONEntry, Field) { assert(self.layer_type_of_root != ARRAY_LAYER, "cannot extract array elements via a key"); let hasher: ByteHasher = ByteHasher {}; @@ -118,11 +118,11 @@ impl(self, key: BoundedVec) -> (JSONEntry, Field) { + fn get_json_entry_unchecked_with_key_index_var(self, key: BoundedVec) -> (JSONEntry, Field) { assert(self.layer_type_of_root != ARRAY_LAYER, "cannot extract array elements via a key"); let hasher: ByteHasher = ByteHasher {}; - let keyhash = hasher.get_keyhash_var(key.storage, 0, key.len as u16); + let keyhash = hasher.get_keyhash_var(key.storage, 0, key.len as u32); let two_pow_216 = 0x100000000000000000000000000000000000000000000000000000000; let keyhash = keyhash + self.root_id * two_pow_216; @@ -139,7 +139,7 @@ impl(self, entry: JSONEntry) -> [u8; StringBytes] { + fn extract_string_entry(self, entry: JSONEntry) -> [u8; StringBytes] { // todo can we make this faster? witness gen for this method is slow // TODO: document that StringBytes parameter includes non-escaped characters assert( @@ -304,7 +304,7 @@ impl(self, key: BoundedVec) -> bool { + fn key_exists(self, key: BoundedVec) -> bool { self.key_exists_impl_var(key).0 } @@ -314,7 +314,7 @@ impl(self, key: [u8; KeyBytes]) -> (bool, Field) { + fn key_exists_impl(self, key: [u8; KeyBytes]) -> (bool, Field) { /* Option A: key exists Option B: key does NOT exist @@ -372,7 +372,7 @@ impl(self, key: BoundedVec) -> (bool, Field) { + fn key_exists_impl_var(self, key: BoundedVec) -> (bool, Field) { /* Option A: key exists Option B: key does NOT exist @@ -384,7 +384,7 @@ impl = ByteHasher {}; - let keyhash = hasher.get_keyhash_var(key.storage, 0, key.len as u16); + let keyhash = hasher.get_keyhash_var(key.storage, 0, key.len as u32); let HASH_MAXIMUM = 0x1000000000000000000000000000000000000000000000000000000000000 - 1; let two_pow_216 = 0x100000000000000000000000000000000000000000000000000000000; @@ -424,7 +424,7 @@ impl(self) -> BoundedVec { + unconstrained fn __get_keys_at_root(self) -> BoundedVec { let mut result: BoundedVec = BoundedVec { len: 0, storage: [0; MaxNumKeys] }; let root_object: JSONEntry = JSONEntry::from(self.json_entries_packed[self.root_index_in_transcript]); @@ -441,7 +441,7 @@ impl(self) -> BoundedVec, MaxNumKeys> { + fn get_keys_at_root(self) -> BoundedVec, MaxNumKeys> { let root_object: JSONEntry = JSONEntry::from(self.json_entries_packed[self.root_index_in_transcript]); let key_indices: BoundedVec = self.__get_keys_at_root(); diff --git a/src/json.nr b/src/json.nr index e7e5e96..397526c 100644 --- a/src/json.nr +++ b/src/json.nr @@ -40,12 +40,12 @@ impl JSONValue { * @description The "root" of the JSON refers to the parent object or array (or a value if the json is just a single value e.g. text = "\"foo\": \"bar\"") * @note text that describes just a single JSON value is not yet fully supported. Only use this library for processing objects or arrays for now **/ -struct JSON { +struct JSON { json: [u8; NumBytes], // the raw json bytes json_packed: [Field; NumPackedFields], // raw bytes, but packed into 31-byte Field elements raw_transcript: [Field; MaxNumTokens], // transcript of json tokens after basic processing transcript: [Field; MaxNumTokens], // complete transcript of json tokens - transcript_length: u16, // how big is the transcript? + transcript_length: u32, // how big is the transcript? key_data: [Field; MaxNumValues], // description of each key, packed into a Field element key_hashes: [Field; MaxNumValues], // a sorted list of key hashes unsorted_json_entries_packed: [JSONEntryPacked; MaxNumValues], // a list of all the processed json values (objects, arrays, numerics, literals, strings) @@ -59,7 +59,7 @@ struct JSON std::cmp::Eq for JSON { +impl std::cmp::Eq for JSON { fn eq(self, other: Self) -> bool { (self.json == other.json) & (self.raw_transcript == other.raw_transcript) @@ -77,12 +77,12 @@ impl JSON { +impl JSON { /** * @brief pack the json bytes into Field elements, where each Field element represents 31 bytes @@ -112,7 +112,7 @@ impl [Field; MaxNumTokens] { let mut raw_transcript: [Field; MaxNumTokens] = [0; MaxNumTokens]; - let mut transcript_ptr: u16 = 0; + let mut transcript_ptr: u32 = 0; let mut scan_mode = GRAMMAR_SCAN as Field; let mut length: Field = 0; let mut previous_was_potential_escape_sequence = 0; @@ -399,7 +399,7 @@ impl [Field; MaxNumTokens] { let mut updated_transcript: [Field; MaxNumTokens] = [0; MaxNumTokens]; - let mut transcript_ptr: u16 = 0; + let mut transcript_ptr: u32 = 0; // TODO: do we need a null transcript value?!?! for i in 0..MaxNumTokens { @@ -515,7 +515,7 @@ impl(stringbytes: [u8; StringBytes]) -> Self { + fn parse_json(stringbytes: [u8; StringBytes]) -> Self { assert(StringBytes <= NumBytes, "json length exceeds NumBytes!"); let mut text: [u8; NumBytes] = [0; NumBytes]; for i in 0..StringBytes { @@ -621,7 +621,7 @@ impl(s: str) -> Self { + fn parse_json_from_string(s: str) -> Self { JSON::parse_json(s.as_bytes()) } } diff --git a/src/keyhash.nr b/src/keyhash.nr index 089373c..0a44d2b 100644 --- a/src/keyhash.nr +++ b/src/keyhash.nr @@ -6,12 +6,12 @@ use crate::_string_tools::slice_field::slice_200_bits_from_field; * when the bytes are represented as packed 31 byte Field elements * @note we wrap `get_keyhash` in a struct so that the KeyFields parameter can be defined ahead of time **/ -struct FieldHasher +struct FieldHasher {} -impl FieldHasher { +impl FieldHasher { - fn get_keyhash( + fn get_keyhash( _: Self, packed_fields: [Field; NumPackedFields], body_index: Field, @@ -29,22 +29,22 @@ impl FieldHasher { * @note we wrap `get_keyhash` in a struct so that the KeyFields parameter can be defined ahead of time * @note produces identical hash outputs when compared w. FieldHasher **/ -struct ByteHasher +struct ByteHasher {} -impl ByteHasher { +impl ByteHasher { fn get_keyhash_var( _: Self, body_text: [u8; N], - body_index: u16, - key_length: u16 + body_index: u32, + key_length: u32 ) -> Field { assert(key_length < KeyFields * 31, "key too large"); let mut key_fields: [Field; KeyFields] = [0; KeyFields]; - let mut key_idx: u16 = 0; + let mut key_idx: u32 = 0; let mut limb = 0; for j in 0..KeyFields { diff --git a/src/keymap.nr b/src/keymap.nr index 938d873..1883ab1 100644 --- a/src/keymap.nr +++ b/src/keymap.nr @@ -45,7 +45,7 @@ impl KeyIndexData { } } -impl JSON { +impl JSON { fn compute_keyhash_and_sort_json_entries(&mut self) { let hasher: FieldHasher = FieldHasher {}; @@ -107,7 +107,7 @@ impl parent_identity_pre as u16) as Field; + // let new_parent = (parent_identity_post as u32 > parent_identity_pre as u32) as Field; // 3.5 gates let index_of_parent = identity_to_json_map[parent_identity_post]; // 1 gate + 3.5 gates diff --git a/src/lib.nr b/src/lib.nr index b89bf3b..8aed082 100644 --- a/src/lib.nr +++ b/src/lib.nr @@ -25,50 +25,50 @@ use crate::get_literal::JSONLiteral; trait JSONParserTrait { - fn parse_json_from_string(s: str) -> Self; - fn parse_json(s: [u8; StringBytes]) -> Self; + fn parse_json_from_string(s: str) -> Self; + fn parse_json(s: [u8; StringBytes]) -> Self; fn get_length(self) -> u32; - fn get_array(self, key: [u8; KeyBytes]) -> Option; - fn get_array_unchecked(self, key: [u8; KeyBytes]) -> Self; - fn get_array_var(self, key: BoundedVec) -> Option; - fn get_array_unchecked_var(self, key: BoundedVec) -> Self; + fn get_array(self, key: [u8; KeyBytes]) -> Option; + fn get_array_unchecked(self, key: [u8; KeyBytes]) -> Self; + fn get_array_var(self, key: BoundedVec) -> Option; + fn get_array_unchecked_var(self, key: BoundedVec) -> Self; fn get_array_from_array(self, array_index: Field) -> Option; fn get_array_from_array_unchecked(self, array_index: Field) -> Self; fn map(self, f: fn(JSONValue) -> U) -> [U; MaxElements] where U: std::default::Default; - fn get_object(self, key: [u8; KeyBytes]) -> Option; - fn get_object_unchecked(self, key: [u8; KeyBytes]) -> Self; - fn get_object_var(self, key: BoundedVec) -> Option; - fn get_object_unchecked_var(self, key: BoundedVec) -> Self; + fn get_object(self, key: [u8; KeyBytes]) -> Option; + fn get_object_unchecked(self, key: [u8; KeyBytes]) -> Self; + fn get_object_var(self, key: BoundedVec) -> Option; + fn get_object_unchecked_var(self, key: BoundedVec) -> Self; fn get_object_from_array(self, array_index: Field) -> Option; fn get_object_from_array_unchecked(self, array_index: Field) -> Self; - fn get_literal(self, key: [u8; KeyBytes]) -> Option; - fn get_literal_unchecked(self, key: [u8; KeyBytes]) -> JSONLiteral; - fn get_literal_var(self, key: BoundedVec) -> Option; - fn get_literal_unchecked_var(self, key: BoundedVec) -> JSONLiteral; + fn get_literal(self, key: [u8; KeyBytes]) -> Option; + fn get_literal_unchecked(self, key: [u8; KeyBytes]) -> JSONLiteral; + fn get_literal_var(self, key: BoundedVec) -> Option; + fn get_literal_unchecked_var(self, key: BoundedVec) -> JSONLiteral; fn get_literal_from_array(self, array_index: Field) -> Option; fn get_literal_from_array_unchecked(self, array_index: Field) -> JSONLiteral; - fn get_number(self, key: [u8; KeyBytes]) -> Option; - fn get_number_unchecked(self, key: [u8; KeyBytes]) -> u64; - fn get_number_var(self, key: BoundedVec) -> Option; - fn get_number_unchecked_var(self, key: BoundedVec) -> u64; + fn get_number(self, key: [u8; KeyBytes]) -> Option; + fn get_number_unchecked(self, key: [u8; KeyBytes]) -> u64; + fn get_number_var(self, key: BoundedVec) -> Option; + fn get_number_unchecked_var(self, key: BoundedVec) -> u64; fn get_number_from_array(self, array_index: Field) -> Option; fn get_number_from_array_unchecked(self, array_index: Field) -> u64; - fn get_string(self, key: [u8; KeyBytes]) -> Option>; - fn get_string_unchecked(self, key: [u8; KeyBytes]) -> BoundedVec; - fn get_string_var(self, key: BoundedVec) -> Option>; - fn get_string_unchecked_var(self, key: BoundedVec) -> BoundedVec; - fn get_string_from_array(self, array_index: Field) -> Option>; - fn get_string_from_array_unchecked(self, array_index: Field) -> BoundedVec; - fn get_string_from_path(self, keys: [BoundedVec; PathDepth]) -> Option>; - fn get_value(self, key: [u8; KeyBytes]) -> Option>; - fn get_value_unchecked(self, key: [u8; KeyBytes]) -> JSONValue; - fn get_value_var(self, key: BoundedVec) -> Option>; - fn get_value_unchecked_var(self, key: BoundedVec) -> JSONValue; - fn get_value_from_array(self, array_index: Field) -> Option>; - fn get_value_from_array_unchecked(self, array_index: Field) -> JSONValue; - fn get_value_from_path(self,keys: [BoundedVec; PathDepth]) -> Option>; - fn key_exists(self, key: BoundedVec) -> bool; - fn get_keys_at_root(self) -> BoundedVec, MaxNumKeys>; + fn get_string(self, key: [u8; KeyBytes]) -> Option>; + fn get_string_unchecked(self, key: [u8; KeyBytes]) -> BoundedVec; + fn get_string_var(self, key: BoundedVec) -> Option>; + fn get_string_unchecked_var(self, key: BoundedVec) -> BoundedVec; + fn get_string_from_array(self, array_index: Field) -> Option>; + fn get_string_from_array_unchecked(self, array_index: Field) -> BoundedVec; + fn get_string_from_path(self, keys: [BoundedVec; PathDepth]) -> Option>; + fn get_value(self, key: [u8; KeyBytes]) -> Option>; + fn get_value_unchecked(self, key: [u8; KeyBytes]) -> JSONValue; + fn get_value_var(self, key: BoundedVec) -> Option>; + fn get_value_unchecked_var(self, key: BoundedVec) -> JSONValue; + fn get_value_from_array(self, array_index: Field) -> Option>; + fn get_value_from_array_unchecked(self, array_index: Field) -> JSONValue; + fn get_value_from_path(self,keys: [BoundedVec; PathDepth]) -> Option>; + fn key_exists(self, key: BoundedVec) -> bool; + fn get_keys_at_root(self) -> BoundedVec, MaxNumKeys>; } mod JSON512b { @@ -83,28 +83,28 @@ mod JSON512b { } } impl crate::JSONParserTrait for JSON { - fn parse_json_from_string(s: str) -> Self { + fn parse_json_from_string(s: str) -> Self { JSON { inner: crate::json::JSON::parse_json_from_string(s) } } - fn parse_json(s: [u8; StringBytes]) -> Self { + fn parse_json(s: [u8; StringBytes]) -> Self { JSON { inner: crate::json::JSON::parse_json(s) } } fn get_length(self) -> u32 { self.inner.get_length() } - fn get_array(self, key: [u8; KeyBytes]) -> Option { + fn get_array(self, key: [u8; KeyBytes]) -> Option { JSON::convert(self.inner.get_array(key)) } - fn get_array_unchecked(self, key: [u8; KeyBytes]) -> Self { + fn get_array_unchecked(self, key: [u8; KeyBytes]) -> Self { JSON { inner: self.inner.get_array_unchecked(key) } } - fn get_array_var(self, key: BoundedVec) -> Option { + fn get_array_var(self, key: BoundedVec) -> Option { { JSON::convert(self.inner.get_array_var(key)) } } - fn get_array_unchecked_var(self, key: BoundedVec) -> Self { + fn get_array_unchecked_var(self, key: BoundedVec) -> Self { JSON { inner: self.inner.get_array_unchecked_var(key) } } fn get_array_from_array(self, array_index: Field) -> Option { @@ -119,20 +119,20 @@ mod JSON512b { ) -> [U; MaxElements] where U: std::default::Default { self.inner.map(f) } - fn get_object(self, key: [u8; KeyBytes]) -> Option { + fn get_object(self, key: [u8; KeyBytes]) -> Option { { JSON::convert(self.inner.get_object(key)) } } - fn get_object_unchecked(self, key: [u8; KeyBytes]) -> Self { + fn get_object_unchecked(self, key: [u8; KeyBytes]) -> Self { JSON { inner: self.inner.get_object_unchecked(key) } } - fn get_object_var(self, key: BoundedVec) -> Option { + fn get_object_var(self, key: BoundedVec) -> Option { { JSON::convert(self.inner.get_object_var(key)) } } - fn get_object_unchecked_var(self, key: BoundedVec) -> Self { + fn get_object_unchecked_var(self, key: BoundedVec) -> Self { JSON { inner: self.inner.get_object_unchecked_var(key) } } fn get_object_from_array(self, array_index: Field) -> Option { @@ -141,16 +141,16 @@ mod JSON512b { fn get_object_from_array_unchecked(self, array_index: Field) -> Self { JSON { inner: self.inner.get_object_from_array_unchecked(array_index) } } - fn get_literal(self, key: [u8; KeyBytes]) -> Option { + fn get_literal(self, key: [u8; KeyBytes]) -> Option { self.inner.get_literal(key) } - fn get_literal_unchecked(self, key: [u8; KeyBytes]) -> crate::JSONLiteral { + fn get_literal_unchecked(self, key: [u8; KeyBytes]) -> crate::JSONLiteral { self.inner.get_literal_unchecked(key) } - fn get_literal_var(self, key: BoundedVec) -> Option { + fn get_literal_var(self, key: BoundedVec) -> Option { self.inner.get_literal_var(key) } - fn get_literal_unchecked_var(self, key: BoundedVec) -> crate::JSONLiteral { + fn get_literal_unchecked_var(self, key: BoundedVec) -> crate::JSONLiteral { self.inner.get_literal_unchecked_var(key) } fn get_literal_from_array(self, array_index: Field) -> Option { @@ -159,16 +159,16 @@ mod JSON512b { fn get_literal_from_array_unchecked(self, array_index: Field) -> crate::JSONLiteral { self.inner.get_literal_from_array_unchecked(array_index) } - fn get_number(self, key: [u8; KeyBytes]) -> Option { + fn get_number(self, key: [u8; KeyBytes]) -> Option { self.inner.get_number(key) } - fn get_number_unchecked(self, key: [u8; KeyBytes]) -> u64 { + fn get_number_unchecked(self, key: [u8; KeyBytes]) -> u64 { self.inner.get_number_unchecked(key) } - fn get_number_var(self, key: BoundedVec) -> Option { + fn get_number_var(self, key: BoundedVec) -> Option { self.inner.get_number_var(key) } - fn get_number_unchecked_var(self, key: BoundedVec) -> u64 { + fn get_number_unchecked_var(self, key: BoundedVec) -> u64 { self.inner.get_number_unchecked_var(key) } fn get_number_from_array(self, array_index: Field) -> Option { @@ -178,59 +178,59 @@ mod JSON512b { self.inner.get_number_from_array_unchecked(array_index) } - fn get_string(self, key: [u8; KeyBytes]) -> Option> { + fn get_string(self, key: [u8; KeyBytes]) -> Option> { self.inner.get_string(key) } - fn get_string_unchecked(self, key: [u8; KeyBytes]) -> BoundedVec { + fn get_string_unchecked(self, key: [u8; KeyBytes]) -> BoundedVec { self.inner.get_string_unchecked(key) } - fn get_string_var(self, key: BoundedVec) -> Option> { + fn get_string_var(self, key: BoundedVec) -> Option> { self.inner.get_string_var(key) } - fn get_string_unchecked_var(self, key: BoundedVec) -> BoundedVec { + fn get_string_unchecked_var(self, key: BoundedVec) -> BoundedVec { self.inner.get_string_unchecked_var(key) } - fn get_string_from_array(self, array_index: Field) -> Option> { + fn get_string_from_array(self, array_index: Field) -> Option> { self.inner.get_string_from_array(array_index) } - fn get_string_from_array_unchecked(self, array_index: Field) -> BoundedVec { + fn get_string_from_array_unchecked(self, array_index: Field) -> BoundedVec { self.inner.get_string_from_array_unchecked(array_index) } - fn get_string_from_path( + fn get_string_from_path( self, keys: [BoundedVec; PathDepth] ) -> Option> { self.inner.get_string_from_path(keys) } - fn get_value(self, key: [u8; KeyBytes]) -> Option> { + fn get_value(self, key: [u8; KeyBytes]) -> Option> { self.inner.get_value(key) } - fn get_value_unchecked(self, key: [u8; KeyBytes]) -> crate::JSONValue { + fn get_value_unchecked(self, key: [u8; KeyBytes]) -> crate::JSONValue { self.inner.get_value_unchecked(key) } - fn get_value_var(self, key: BoundedVec) -> Option> { + fn get_value_var(self, key: BoundedVec) -> Option> { self.inner.get_value_var(key) } - fn get_value_unchecked_var(self, key: BoundedVec) -> crate::JSONValue { + fn get_value_unchecked_var(self, key: BoundedVec) -> crate::JSONValue { self.inner.get_value_unchecked_var(key) } - fn get_value_from_array(self, array_index: Field) -> Option> { + fn get_value_from_array(self, array_index: Field) -> Option> { self.inner.get_value_from_array(array_index) } - fn get_value_from_array_unchecked(self, array_index: Field) -> crate::JSONValue { + fn get_value_from_array_unchecked(self, array_index: Field) -> crate::JSONValue { self.inner.get_value_from_array_unchecked(array_index) } - fn get_value_from_path( + fn get_value_from_path( self, keys: [BoundedVec; PathDepth] ) -> Option> { self.inner.get_value_from_path(keys) } - fn key_exists(self, key: BoundedVec) -> bool { + fn key_exists(self, key: BoundedVec) -> bool { self.inner.key_exists(key) } - fn get_keys_at_root(self) -> BoundedVec, MaxNumKeys> { + fn get_keys_at_root(self) -> BoundedVec, MaxNumKeys> { self.inner.get_keys_at_root() } } @@ -247,28 +247,28 @@ mod JSON1kb { } } impl crate::JSONParserTrait for JSON { - fn parse_json_from_string(s: str) -> Self { + fn parse_json_from_string(s: str) -> Self { JSON { inner: crate::json::JSON::parse_json_from_string(s) } } - fn parse_json(s: [u8; StringBytes]) -> Self { + fn parse_json(s: [u8; StringBytes]) -> Self { JSON { inner: crate::json::JSON::parse_json(s) } } fn get_length(self) -> u32 { self.inner.get_length() } - fn get_array(self, key: [u8; KeyBytes]) -> Option { + fn get_array(self, key: [u8; KeyBytes]) -> Option { JSON::convert(self.inner.get_array(key)) } - fn get_array_unchecked(self, key: [u8; KeyBytes]) -> Self { + fn get_array_unchecked(self, key: [u8; KeyBytes]) -> Self { JSON { inner: self.inner.get_array_unchecked(key) } } - fn get_array_var(self, key: BoundedVec) -> Option { + fn get_array_var(self, key: BoundedVec) -> Option { { JSON::convert(self.inner.get_array_var(key)) } } - fn get_array_unchecked_var(self, key: BoundedVec) -> Self { + fn get_array_unchecked_var(self, key: BoundedVec) -> Self { JSON { inner: self.inner.get_array_unchecked_var(key) } } fn get_array_from_array(self, array_index: Field) -> Option { @@ -283,20 +283,20 @@ mod JSON1kb { ) -> [U; MaxElements] where U: std::default::Default { self.inner.map(f) } - fn get_object(self, key: [u8; KeyBytes]) -> Option { + fn get_object(self, key: [u8; KeyBytes]) -> Option { { JSON::convert(self.inner.get_object(key)) } } - fn get_object_unchecked(self, key: [u8; KeyBytes]) -> Self { + fn get_object_unchecked(self, key: [u8; KeyBytes]) -> Self { JSON { inner: self.inner.get_object_unchecked(key) } } - fn get_object_var(self, key: BoundedVec) -> Option { + fn get_object_var(self, key: BoundedVec) -> Option { { JSON::convert(self.inner.get_object_var(key)) } } - fn get_object_unchecked_var(self, key: BoundedVec) -> Self { + fn get_object_unchecked_var(self, key: BoundedVec) -> Self { JSON { inner: self.inner.get_object_unchecked_var(key) } } fn get_object_from_array(self, array_index: Field) -> Option { @@ -305,16 +305,16 @@ mod JSON1kb { fn get_object_from_array_unchecked(self, array_index: Field) -> Self { JSON { inner: self.inner.get_object_from_array_unchecked(array_index) } } - fn get_literal(self, key: [u8; KeyBytes]) -> Option { + fn get_literal(self, key: [u8; KeyBytes]) -> Option { self.inner.get_literal(key) } - fn get_literal_unchecked(self, key: [u8; KeyBytes]) -> crate::JSONLiteral { + fn get_literal_unchecked(self, key: [u8; KeyBytes]) -> crate::JSONLiteral { self.inner.get_literal_unchecked(key) } - fn get_literal_var(self, key: BoundedVec) -> Option { + fn get_literal_var(self, key: BoundedVec) -> Option { self.inner.get_literal_var(key) } - fn get_literal_unchecked_var(self, key: BoundedVec) -> crate::JSONLiteral { + fn get_literal_unchecked_var(self, key: BoundedVec) -> crate::JSONLiteral { self.inner.get_literal_unchecked_var(key) } fn get_literal_from_array(self, array_index: Field) -> Option { @@ -323,16 +323,16 @@ mod JSON1kb { fn get_literal_from_array_unchecked(self, array_index: Field) -> crate::JSONLiteral { self.inner.get_literal_from_array_unchecked(array_index) } - fn get_number(self, key: [u8; KeyBytes]) -> Option { + fn get_number(self, key: [u8; KeyBytes]) -> Option { self.inner.get_number(key) } - fn get_number_unchecked(self, key: [u8; KeyBytes]) -> u64 { + fn get_number_unchecked(self, key: [u8; KeyBytes]) -> u64 { self.inner.get_number_unchecked(key) } - fn get_number_var(self, key: BoundedVec) -> Option { + fn get_number_var(self, key: BoundedVec) -> Option { self.inner.get_number_var(key) } - fn get_number_unchecked_var(self, key: BoundedVec) -> u64 { + fn get_number_unchecked_var(self, key: BoundedVec) -> u64 { self.inner.get_number_unchecked_var(key) } fn get_number_from_array(self, array_index: Field) -> Option { @@ -341,58 +341,58 @@ mod JSON1kb { fn get_number_from_array_unchecked(self, array_index: Field) -> u64 { self.inner.get_number_from_array_unchecked(array_index) } - fn get_string(self, key: [u8; KeyBytes]) -> Option> { + fn get_string(self, key: [u8; KeyBytes]) -> Option> { self.inner.get_string(key) } - fn get_string_unchecked(self, key: [u8; KeyBytes]) -> BoundedVec { + fn get_string_unchecked(self, key: [u8; KeyBytes]) -> BoundedVec { self.inner.get_string_unchecked(key) } - fn get_string_var(self, key: BoundedVec) -> Option> { + fn get_string_var(self, key: BoundedVec) -> Option> { self.inner.get_string_var(key) } - fn get_string_unchecked_var(self, key: BoundedVec) -> BoundedVec { + fn get_string_unchecked_var(self, key: BoundedVec) -> BoundedVec { self.inner.get_string_unchecked_var(key) } - fn get_string_from_array(self, array_index: Field) -> Option> { + fn get_string_from_array(self, array_index: Field) -> Option> { self.inner.get_string_from_array(array_index) } - fn get_string_from_array_unchecked(self, array_index: Field) -> BoundedVec { + fn get_string_from_array_unchecked(self, array_index: Field) -> BoundedVec { self.inner.get_string_from_array_unchecked(array_index) } - fn get_string_from_path( + fn get_string_from_path( self, keys: [BoundedVec; PathDepth] ) -> Option> { self.inner.get_string_from_path(keys) } - fn get_value(self, key: [u8; KeyBytes]) -> Option> { + fn get_value(self, key: [u8; KeyBytes]) -> Option> { self.inner.get_value(key) } - fn get_value_unchecked(self, key: [u8; KeyBytes]) -> crate::JSONValue { + fn get_value_unchecked(self, key: [u8; KeyBytes]) -> crate::JSONValue { self.inner.get_value_unchecked(key) } - fn get_value_var(self, key: BoundedVec) -> Option> { + fn get_value_var(self, key: BoundedVec) -> Option> { self.inner.get_value_var(key) } - fn get_value_unchecked_var(self, key: BoundedVec) -> crate::JSONValue { + fn get_value_unchecked_var(self, key: BoundedVec) -> crate::JSONValue { self.inner.get_value_unchecked_var(key) } - fn get_value_from_array(self, array_index: Field) -> Option> { + fn get_value_from_array(self, array_index: Field) -> Option> { self.inner.get_value_from_array(array_index) } - fn get_value_from_array_unchecked(self, array_index: Field) -> crate::JSONValue { + fn get_value_from_array_unchecked(self, array_index: Field) -> crate::JSONValue { self.inner.get_value_from_array_unchecked(array_index) } - fn get_value_from_path( + fn get_value_from_path( self, keys: [BoundedVec; PathDepth] ) -> Option> { self.inner.get_value_from_path(keys) } - fn key_exists(self, key: BoundedVec) -> bool { + fn key_exists(self, key: BoundedVec) -> bool { self.inner.key_exists(key) } - fn get_keys_at_root(self) -> BoundedVec, MaxNumKeys> { + fn get_keys_at_root(self) -> BoundedVec, MaxNumKeys> { self.inner.get_keys_at_root() } } @@ -409,28 +409,28 @@ mod JSON2kb { } } impl crate::JSONParserTrait for JSON { - fn parse_json_from_string(s: str) -> Self { + fn parse_json_from_string(s: str) -> Self { JSON { inner: crate::json::JSON::parse_json_from_string(s) } } - fn parse_json(s: [u8; StringBytes]) -> Self { + fn parse_json(s: [u8; StringBytes]) -> Self { JSON { inner: crate::json::JSON::parse_json(s) } } fn get_length(self) -> u32 { self.inner.get_length() } - fn get_array(self, key: [u8; KeyBytes]) -> Option { + fn get_array(self, key: [u8; KeyBytes]) -> Option { JSON::convert(self.inner.get_array(key)) } - fn get_array_unchecked(self, key: [u8; KeyBytes]) -> Self { + fn get_array_unchecked(self, key: [u8; KeyBytes]) -> Self { JSON { inner: self.inner.get_array_unchecked(key) } } - fn get_array_var(self, key: BoundedVec) -> Option { + fn get_array_var(self, key: BoundedVec) -> Option { { JSON::convert(self.inner.get_array_var(key)) } } - fn get_array_unchecked_var(self, key: BoundedVec) -> Self { + fn get_array_unchecked_var(self, key: BoundedVec) -> Self { JSON { inner: self.inner.get_array_unchecked_var(key) } } fn get_array_from_array(self, array_index: Field) -> Option { @@ -445,20 +445,20 @@ mod JSON2kb { ) -> [U; MaxElements] where U: std::default::Default { self.inner.map(f) } - fn get_object(self, key: [u8; KeyBytes]) -> Option { + fn get_object(self, key: [u8; KeyBytes]) -> Option { { JSON::convert(self.inner.get_object(key)) } } - fn get_object_unchecked(self, key: [u8; KeyBytes]) -> Self { + fn get_object_unchecked(self, key: [u8; KeyBytes]) -> Self { JSON { inner: self.inner.get_object_unchecked(key) } } - fn get_object_var(self, key: BoundedVec) -> Option { + fn get_object_var(self, key: BoundedVec) -> Option { { JSON::convert(self.inner.get_object_var(key)) } } - fn get_object_unchecked_var(self, key: BoundedVec) -> Self { + fn get_object_unchecked_var(self, key: BoundedVec) -> Self { JSON { inner: self.inner.get_object_unchecked_var(key) } } fn get_object_from_array(self, array_index: Field) -> Option { @@ -467,16 +467,16 @@ mod JSON2kb { fn get_object_from_array_unchecked(self, array_index: Field) -> Self { JSON { inner: self.inner.get_object_from_array_unchecked(array_index) } } - fn get_literal(self, key: [u8; KeyBytes]) -> Option { + fn get_literal(self, key: [u8; KeyBytes]) -> Option { self.inner.get_literal(key) } - fn get_literal_unchecked(self, key: [u8; KeyBytes]) -> crate::JSONLiteral { + fn get_literal_unchecked(self, key: [u8; KeyBytes]) -> crate::JSONLiteral { self.inner.get_literal_unchecked(key) } - fn get_literal_var(self, key: BoundedVec) -> Option { + fn get_literal_var(self, key: BoundedVec) -> Option { self.inner.get_literal_var(key) } - fn get_literal_unchecked_var(self, key: BoundedVec) -> crate::JSONLiteral { + fn get_literal_unchecked_var(self, key: BoundedVec) -> crate::JSONLiteral { self.inner.get_literal_unchecked_var(key) } fn get_literal_from_array(self, array_index: Field) -> Option { @@ -485,16 +485,16 @@ mod JSON2kb { fn get_literal_from_array_unchecked(self, array_index: Field) -> crate::JSONLiteral { self.inner.get_literal_from_array_unchecked(array_index) } - fn get_number(self, key: [u8; KeyBytes]) -> Option { + fn get_number(self, key: [u8; KeyBytes]) -> Option { self.inner.get_number(key) } - fn get_number_unchecked(self, key: [u8; KeyBytes]) -> u64 { + fn get_number_unchecked(self, key: [u8; KeyBytes]) -> u64 { self.inner.get_number_unchecked(key) } - fn get_number_var(self, key: BoundedVec) -> Option { + fn get_number_var(self, key: BoundedVec) -> Option { self.inner.get_number_var(key) } - fn get_number_unchecked_var(self, key: BoundedVec) -> u64 { + fn get_number_unchecked_var(self, key: BoundedVec) -> u64 { self.inner.get_number_unchecked_var(key) } fn get_number_from_array(self, array_index: Field) -> Option { @@ -503,58 +503,58 @@ mod JSON2kb { fn get_number_from_array_unchecked(self, array_index: Field) -> u64 { self.inner.get_number_from_array_unchecked(array_index) } - fn get_string(self, key: [u8; KeyBytes]) -> Option> { + fn get_string(self, key: [u8; KeyBytes]) -> Option> { self.inner.get_string(key) } - fn get_string_unchecked(self, key: [u8; KeyBytes]) -> BoundedVec { + fn get_string_unchecked(self, key: [u8; KeyBytes]) -> BoundedVec { self.inner.get_string_unchecked(key) } - fn get_string_var(self, key: BoundedVec) -> Option> { + fn get_string_var(self, key: BoundedVec) -> Option> { self.inner.get_string_var(key) } - fn get_string_unchecked_var(self, key: BoundedVec) -> BoundedVec { + fn get_string_unchecked_var(self, key: BoundedVec) -> BoundedVec { self.inner.get_string_unchecked_var(key) } - fn get_string_from_array(self, array_index: Field) -> Option> { + fn get_string_from_array(self, array_index: Field) -> Option> { self.inner.get_string_from_array(array_index) } - fn get_string_from_array_unchecked(self, array_index: Field) -> BoundedVec { + fn get_string_from_array_unchecked(self, array_index: Field) -> BoundedVec { self.inner.get_string_from_array_unchecked(array_index) } - fn get_string_from_path( + fn get_string_from_path( self, keys: [BoundedVec; PathDepth] ) -> Option> { self.inner.get_string_from_path(keys) } - fn get_value(self, key: [u8; KeyBytes]) -> Option> { + fn get_value(self, key: [u8; KeyBytes]) -> Option> { self.inner.get_value(key) } - fn get_value_unchecked(self, key: [u8; KeyBytes]) -> crate::JSONValue { + fn get_value_unchecked(self, key: [u8; KeyBytes]) -> crate::JSONValue { self.inner.get_value_unchecked(key) } - fn get_value_var(self, key: BoundedVec) -> Option> { + fn get_value_var(self, key: BoundedVec) -> Option> { self.inner.get_value_var(key) } - fn get_value_unchecked_var(self, key: BoundedVec) -> crate::JSONValue { + fn get_value_unchecked_var(self, key: BoundedVec) -> crate::JSONValue { self.inner.get_value_unchecked_var(key) } - fn get_value_from_array(self, array_index: Field) -> Option> { + fn get_value_from_array(self, array_index: Field) -> Option> { self.inner.get_value_from_array(array_index) } - fn get_value_from_array_unchecked(self, array_index: Field) -> crate::JSONValue { + fn get_value_from_array_unchecked(self, array_index: Field) -> crate::JSONValue { self.inner.get_value_from_array_unchecked(array_index) } - fn get_value_from_path( + fn get_value_from_path( self, keys: [BoundedVec; PathDepth] ) -> Option> { self.inner.get_value_from_path(keys) } - fn key_exists(self, key: BoundedVec) -> bool { + fn key_exists(self, key: BoundedVec) -> bool { self.inner.key_exists(key) } - fn get_keys_at_root(self) -> BoundedVec, MaxNumKeys> { + fn get_keys_at_root(self) -> BoundedVec, MaxNumKeys> { self.inner.get_keys_at_root() } } @@ -571,28 +571,28 @@ mod JSON4kb { } } impl crate::JSONParserTrait for JSON { - fn parse_json_from_string(s: str) -> Self { + fn parse_json_from_string(s: str) -> Self { JSON { inner: crate::json::JSON::parse_json_from_string(s) } } - fn parse_json(s: [u8; StringBytes]) -> Self { + fn parse_json(s: [u8; StringBytes]) -> Self { JSON { inner: crate::json::JSON::parse_json(s) } } fn get_length(self) -> u32 { self.inner.get_length() } - fn get_array(self, key: [u8; KeyBytes]) -> Option { + fn get_array(self, key: [u8; KeyBytes]) -> Option { JSON::convert(self.inner.get_array(key)) } - fn get_array_unchecked(self, key: [u8; KeyBytes]) -> Self { + fn get_array_unchecked(self, key: [u8; KeyBytes]) -> Self { JSON { inner: self.inner.get_array_unchecked(key) } } - fn get_array_var(self, key: BoundedVec) -> Option { + fn get_array_var(self, key: BoundedVec) -> Option { { JSON::convert(self.inner.get_array_var(key)) } } - fn get_array_unchecked_var(self, key: BoundedVec) -> Self { + fn get_array_unchecked_var(self, key: BoundedVec) -> Self { JSON { inner: self.inner.get_array_unchecked_var(key) } } fn get_array_from_array(self, array_index: Field) -> Option { @@ -607,20 +607,20 @@ mod JSON4kb { ) -> [U; MaxElements] where U: std::default::Default { self.inner.map(f) } - fn get_object(self, key: [u8; KeyBytes]) -> Option { + fn get_object(self, key: [u8; KeyBytes]) -> Option { { JSON::convert(self.inner.get_object(key)) } } - fn get_object_unchecked(self, key: [u8; KeyBytes]) -> Self { + fn get_object_unchecked(self, key: [u8; KeyBytes]) -> Self { JSON { inner: self.inner.get_object_unchecked(key) } } - fn get_object_var(self, key: BoundedVec) -> Option { + fn get_object_var(self, key: BoundedVec) -> Option { { JSON::convert(self.inner.get_object_var(key)) } } - fn get_object_unchecked_var(self, key: BoundedVec) -> Self { + fn get_object_unchecked_var(self, key: BoundedVec) -> Self { JSON { inner: self.inner.get_object_unchecked_var(key) } } fn get_object_from_array(self, array_index: Field) -> Option { @@ -629,16 +629,16 @@ mod JSON4kb { fn get_object_from_array_unchecked(self, array_index: Field) -> Self { JSON { inner: self.inner.get_object_from_array_unchecked(array_index) } } - fn get_literal(self, key: [u8; KeyBytes]) -> Option { + fn get_literal(self, key: [u8; KeyBytes]) -> Option { self.inner.get_literal(key) } - fn get_literal_unchecked(self, key: [u8; KeyBytes]) -> crate::JSONLiteral { + fn get_literal_unchecked(self, key: [u8; KeyBytes]) -> crate::JSONLiteral { self.inner.get_literal_unchecked(key) } - fn get_literal_var(self, key: BoundedVec) -> Option { + fn get_literal_var(self, key: BoundedVec) -> Option { self.inner.get_literal_var(key) } - fn get_literal_unchecked_var(self, key: BoundedVec) -> crate::JSONLiteral { + fn get_literal_unchecked_var(self, key: BoundedVec) -> crate::JSONLiteral { self.inner.get_literal_unchecked_var(key) } fn get_literal_from_array(self, array_index: Field) -> Option { @@ -647,16 +647,16 @@ mod JSON4kb { fn get_literal_from_array_unchecked(self, array_index: Field) -> crate::JSONLiteral { self.inner.get_literal_from_array_unchecked(array_index) } - fn get_number(self, key: [u8; KeyBytes]) -> Option { + fn get_number(self, key: [u8; KeyBytes]) -> Option { self.inner.get_number(key) } - fn get_number_unchecked(self, key: [u8; KeyBytes]) -> u64 { + fn get_number_unchecked(self, key: [u8; KeyBytes]) -> u64 { self.inner.get_number_unchecked(key) } - fn get_number_var(self, key: BoundedVec) -> Option { + fn get_number_var(self, key: BoundedVec) -> Option { self.inner.get_number_var(key) } - fn get_number_unchecked_var(self, key: BoundedVec) -> u64 { + fn get_number_unchecked_var(self, key: BoundedVec) -> u64 { self.inner.get_number_unchecked_var(key) } fn get_number_from_array(self, array_index: Field) -> Option { @@ -665,58 +665,58 @@ mod JSON4kb { fn get_number_from_array_unchecked(self, array_index: Field) -> u64 { self.inner.get_number_from_array_unchecked(array_index) } - fn get_string(self, key: [u8; KeyBytes]) -> Option> { + fn get_string(self, key: [u8; KeyBytes]) -> Option> { self.inner.get_string(key) } - fn get_string_unchecked(self, key: [u8; KeyBytes]) -> BoundedVec { + fn get_string_unchecked(self, key: [u8; KeyBytes]) -> BoundedVec { self.inner.get_string_unchecked(key) } - fn get_string_var(self, key: BoundedVec) -> Option> { + fn get_string_var(self, key: BoundedVec) -> Option> { self.inner.get_string_var(key) } - fn get_string_unchecked_var(self, key: BoundedVec) -> BoundedVec { + fn get_string_unchecked_var(self, key: BoundedVec) -> BoundedVec { self.inner.get_string_unchecked_var(key) } - fn get_string_from_array(self, array_index: Field) -> Option> { + fn get_string_from_array(self, array_index: Field) -> Option> { self.inner.get_string_from_array(array_index) } - fn get_string_from_array_unchecked(self, array_index: Field) -> BoundedVec { + fn get_string_from_array_unchecked(self, array_index: Field) -> BoundedVec { self.inner.get_string_from_array_unchecked(array_index) } - fn get_string_from_path( + fn get_string_from_path( self, keys: [BoundedVec; PathDepth] ) -> Option> { self.inner.get_string_from_path(keys) } - fn get_value(self, key: [u8; KeyBytes]) -> Option> { + fn get_value(self, key: [u8; KeyBytes]) -> Option> { self.inner.get_value(key) } - fn get_value_unchecked(self, key: [u8; KeyBytes]) -> crate::JSONValue { + fn get_value_unchecked(self, key: [u8; KeyBytes]) -> crate::JSONValue { self.inner.get_value_unchecked(key) } - fn get_value_var(self, key: BoundedVec) -> Option> { + fn get_value_var(self, key: BoundedVec) -> Option> { self.inner.get_value_var(key) } - fn get_value_unchecked_var(self, key: BoundedVec) -> crate::JSONValue { + fn get_value_unchecked_var(self, key: BoundedVec) -> crate::JSONValue { self.inner.get_value_unchecked_var(key) } - fn get_value_from_array(self, array_index: Field) -> Option> { + fn get_value_from_array(self, array_index: Field) -> Option> { self.inner.get_value_from_array(array_index) } - fn get_value_from_array_unchecked(self, array_index: Field) -> crate::JSONValue { + fn get_value_from_array_unchecked(self, array_index: Field) -> crate::JSONValue { self.inner.get_value_from_array_unchecked(array_index) } - fn get_value_from_path( + fn get_value_from_path( self, keys: [BoundedVec; PathDepth] ) -> Option> { self.inner.get_value_from_path(keys) } - fn key_exists(self, key: BoundedVec) -> bool { + fn key_exists(self, key: BoundedVec) -> bool { self.inner.key_exists(key) } - fn get_keys_at_root(self) -> BoundedVec, MaxNumKeys> { + fn get_keys_at_root(self) -> BoundedVec, MaxNumKeys> { self.inner.get_keys_at_root() } } @@ -733,28 +733,28 @@ mod JSON8kb { } } impl crate::JSONParserTrait for JSON { - fn parse_json_from_string(s: str) -> Self { + fn parse_json_from_string(s: str) -> Self { JSON { inner: crate::json::JSON::parse_json_from_string(s) } } - fn parse_json(s: [u8; StringBytes]) -> Self { + fn parse_json(s: [u8; StringBytes]) -> Self { JSON { inner: crate::json::JSON::parse_json(s) } } fn get_length(self) -> u32 { self.inner.get_length() } - fn get_array(self, key: [u8; KeyBytes]) -> Option { + fn get_array(self, key: [u8; KeyBytes]) -> Option { JSON::convert(self.inner.get_array(key)) } - fn get_array_unchecked(self, key: [u8; KeyBytes]) -> Self { + fn get_array_unchecked(self, key: [u8; KeyBytes]) -> Self { JSON { inner: self.inner.get_array_unchecked(key) } } - fn get_array_var(self, key: BoundedVec) -> Option { + fn get_array_var(self, key: BoundedVec) -> Option { { JSON::convert(self.inner.get_array_var(key)) } } - fn get_array_unchecked_var(self, key: BoundedVec) -> Self { + fn get_array_unchecked_var(self, key: BoundedVec) -> Self { JSON { inner: self.inner.get_array_unchecked_var(key) } } fn get_array_from_array(self, array_index: Field) -> Option { @@ -769,20 +769,20 @@ mod JSON8kb { ) -> [U; MaxElements] where U: std::default::Default { self.inner.map(f) } - fn get_object(self, key: [u8; KeyBytes]) -> Option { + fn get_object(self, key: [u8; KeyBytes]) -> Option { { JSON::convert(self.inner.get_object(key)) } } - fn get_object_unchecked(self, key: [u8; KeyBytes]) -> Self { + fn get_object_unchecked(self, key: [u8; KeyBytes]) -> Self { JSON { inner: self.inner.get_object_unchecked(key) } } - fn get_object_var(self, key: BoundedVec) -> Option { + fn get_object_var(self, key: BoundedVec) -> Option { { JSON::convert(self.inner.get_object_var(key)) } } - fn get_object_unchecked_var(self, key: BoundedVec) -> Self { + fn get_object_unchecked_var(self, key: BoundedVec) -> Self { JSON { inner: self.inner.get_object_unchecked_var(key) } } fn get_object_from_array(self, array_index: Field) -> Option { @@ -791,16 +791,16 @@ mod JSON8kb { fn get_object_from_array_unchecked(self, array_index: Field) -> Self { JSON { inner: self.inner.get_object_from_array_unchecked(array_index) } } - fn get_literal(self, key: [u8; KeyBytes]) -> Option { + fn get_literal(self, key: [u8; KeyBytes]) -> Option { self.inner.get_literal(key) } - fn get_literal_unchecked(self, key: [u8; KeyBytes]) -> crate::JSONLiteral { + fn get_literal_unchecked(self, key: [u8; KeyBytes]) -> crate::JSONLiteral { self.inner.get_literal_unchecked(key) } - fn get_literal_var(self, key: BoundedVec) -> Option { + fn get_literal_var(self, key: BoundedVec) -> Option { self.inner.get_literal_var(key) } - fn get_literal_unchecked_var(self, key: BoundedVec) -> crate::JSONLiteral { + fn get_literal_unchecked_var(self, key: BoundedVec) -> crate::JSONLiteral { self.inner.get_literal_unchecked_var(key) } fn get_literal_from_array(self, array_index: Field) -> Option { @@ -809,16 +809,16 @@ mod JSON8kb { fn get_literal_from_array_unchecked(self, array_index: Field) -> crate::JSONLiteral { self.inner.get_literal_from_array_unchecked(array_index) } - fn get_number(self, key: [u8; KeyBytes]) -> Option { + fn get_number(self, key: [u8; KeyBytes]) -> Option { self.inner.get_number(key) } - fn get_number_unchecked(self, key: [u8; KeyBytes]) -> u64 { + fn get_number_unchecked(self, key: [u8; KeyBytes]) -> u64 { self.inner.get_number_unchecked(key) } - fn get_number_var(self, key: BoundedVec) -> Option { + fn get_number_var(self, key: BoundedVec) -> Option { self.inner.get_number_var(key) } - fn get_number_unchecked_var(self, key: BoundedVec) -> u64 { + fn get_number_unchecked_var(self, key: BoundedVec) -> u64 { self.inner.get_number_unchecked_var(key) } fn get_number_from_array(self, array_index: Field) -> Option { @@ -827,58 +827,58 @@ mod JSON8kb { fn get_number_from_array_unchecked(self, array_index: Field) -> u64 { self.inner.get_number_from_array_unchecked(array_index) } - fn get_string(self, key: [u8; KeyBytes]) -> Option> { + fn get_string(self, key: [u8; KeyBytes]) -> Option> { self.inner.get_string(key) } - fn get_string_unchecked(self, key: [u8; KeyBytes]) -> BoundedVec { + fn get_string_unchecked(self, key: [u8; KeyBytes]) -> BoundedVec { self.inner.get_string_unchecked(key) } - fn get_string_var(self, key: BoundedVec) -> Option> { + fn get_string_var(self, key: BoundedVec) -> Option> { self.inner.get_string_var(key) } - fn get_string_unchecked_var(self, key: BoundedVec) -> BoundedVec { + fn get_string_unchecked_var(self, key: BoundedVec) -> BoundedVec { self.inner.get_string_unchecked_var(key) } - fn get_string_from_array(self, array_index: Field) -> Option> { + fn get_string_from_array(self, array_index: Field) -> Option> { self.inner.get_string_from_array(array_index) } - fn get_string_from_array_unchecked(self, array_index: Field) -> BoundedVec { + fn get_string_from_array_unchecked(self, array_index: Field) -> BoundedVec { self.inner.get_string_from_array_unchecked(array_index) } - fn get_string_from_path( + fn get_string_from_path( self, keys: [BoundedVec; PathDepth] ) -> Option> { self.inner.get_string_from_path(keys) } - fn get_value(self, key: [u8; KeyBytes]) -> Option> { + fn get_value(self, key: [u8; KeyBytes]) -> Option> { self.inner.get_value(key) } - fn get_value_unchecked(self, key: [u8; KeyBytes]) -> crate::JSONValue { + fn get_value_unchecked(self, key: [u8; KeyBytes]) -> crate::JSONValue { self.inner.get_value_unchecked(key) } - fn get_value_var(self, key: BoundedVec) -> Option> { + fn get_value_var(self, key: BoundedVec) -> Option> { self.inner.get_value_var(key) } - fn get_value_unchecked_var(self, key: BoundedVec) -> crate::JSONValue { + fn get_value_unchecked_var(self, key: BoundedVec) -> crate::JSONValue { self.inner.get_value_unchecked_var(key) } - fn get_value_from_array(self, array_index: Field) -> Option> { + fn get_value_from_array(self, array_index: Field) -> Option> { self.inner.get_value_from_array(array_index) } - fn get_value_from_array_unchecked(self, array_index: Field) -> crate::JSONValue { + fn get_value_from_array_unchecked(self, array_index: Field) -> crate::JSONValue { self.inner.get_value_from_array_unchecked(array_index) } - fn get_value_from_path( + fn get_value_from_path( self, keys: [BoundedVec; PathDepth] ) -> Option> { self.inner.get_value_from_path(keys) } - fn key_exists(self, key: BoundedVec) -> bool { + fn key_exists(self, key: BoundedVec) -> bool { self.inner.key_exists(key) } - fn get_keys_at_root(self) -> BoundedVec, MaxNumKeys> { + fn get_keys_at_root(self) -> BoundedVec, MaxNumKeys> { self.inner.get_keys_at_root() } } @@ -895,28 +895,28 @@ mod JSON16kb { } } impl crate::JSONParserTrait for JSON { - fn parse_json_from_string(s: str) -> Self { + fn parse_json_from_string(s: str) -> Self { JSON { inner: crate::json::JSON::parse_json_from_string(s) } } - fn parse_json(s: [u8; StringBytes]) -> Self { + fn parse_json(s: [u8; StringBytes]) -> Self { JSON { inner: crate::json::JSON::parse_json(s) } } fn get_length(self) -> u32 { self.inner.get_length() } - fn get_array(self, key: [u8; KeyBytes]) -> Option { + fn get_array(self, key: [u8; KeyBytes]) -> Option { JSON::convert(self.inner.get_array(key)) } - fn get_array_unchecked(self, key: [u8; KeyBytes]) -> Self { + fn get_array_unchecked(self, key: [u8; KeyBytes]) -> Self { JSON { inner: self.inner.get_array_unchecked(key) } } - fn get_array_var(self, key: BoundedVec) -> Option { + fn get_array_var(self, key: BoundedVec) -> Option { { JSON::convert(self.inner.get_array_var(key)) } } - fn get_array_unchecked_var(self, key: BoundedVec) -> Self { + fn get_array_unchecked_var(self, key: BoundedVec) -> Self { JSON { inner: self.inner.get_array_unchecked_var(key) } } fn get_array_from_array(self, array_index: Field) -> Option { @@ -931,20 +931,20 @@ mod JSON16kb { ) -> [U; MaxElements] where U: std::default::Default { self.inner.map(f) } - fn get_object(self, key: [u8; KeyBytes]) -> Option { + fn get_object(self, key: [u8; KeyBytes]) -> Option { { JSON::convert(self.inner.get_object(key)) } } - fn get_object_unchecked(self, key: [u8; KeyBytes]) -> Self { + fn get_object_unchecked(self, key: [u8; KeyBytes]) -> Self { JSON { inner: self.inner.get_object_unchecked(key) } } - fn get_object_var(self, key: BoundedVec) -> Option { + fn get_object_var(self, key: BoundedVec) -> Option { { JSON::convert(self.inner.get_object_var(key)) } } - fn get_object_unchecked_var(self, key: BoundedVec) -> Self { + fn get_object_unchecked_var(self, key: BoundedVec) -> Self { JSON { inner: self.inner.get_object_unchecked_var(key) } } fn get_object_from_array(self, array_index: Field) -> Option { @@ -953,16 +953,16 @@ mod JSON16kb { fn get_object_from_array_unchecked(self, array_index: Field) -> Self { JSON { inner: self.inner.get_object_from_array_unchecked(array_index) } } - fn get_literal(self, key: [u8; KeyBytes]) -> Option { + fn get_literal(self, key: [u8; KeyBytes]) -> Option { self.inner.get_literal(key) } - fn get_literal_unchecked(self, key: [u8; KeyBytes]) -> crate::JSONLiteral { + fn get_literal_unchecked(self, key: [u8; KeyBytes]) -> crate::JSONLiteral { self.inner.get_literal_unchecked(key) } - fn get_literal_var(self, key: BoundedVec) -> Option { + fn get_literal_var(self, key: BoundedVec) -> Option { self.inner.get_literal_var(key) } - fn get_literal_unchecked_var(self, key: BoundedVec) -> crate::JSONLiteral { + fn get_literal_unchecked_var(self, key: BoundedVec) -> crate::JSONLiteral { self.inner.get_literal_unchecked_var(key) } fn get_literal_from_array(self, array_index: Field) -> Option { @@ -971,16 +971,16 @@ mod JSON16kb { fn get_literal_from_array_unchecked(self, array_index: Field) -> crate::JSONLiteral { self.inner.get_literal_from_array_unchecked(array_index) } - fn get_number(self, key: [u8; KeyBytes]) -> Option { + fn get_number(self, key: [u8; KeyBytes]) -> Option { self.inner.get_number(key) } - fn get_number_unchecked(self, key: [u8; KeyBytes]) -> u64 { + fn get_number_unchecked(self, key: [u8; KeyBytes]) -> u64 { self.inner.get_number_unchecked(key) } - fn get_number_var(self, key: BoundedVec) -> Option { + fn get_number_var(self, key: BoundedVec) -> Option { self.inner.get_number_var(key) } - fn get_number_unchecked_var(self, key: BoundedVec) -> u64 { + fn get_number_unchecked_var(self, key: BoundedVec) -> u64 { self.inner.get_number_unchecked_var(key) } fn get_number_from_array(self, array_index: Field) -> Option { @@ -989,58 +989,58 @@ mod JSON16kb { fn get_number_from_array_unchecked(self, array_index: Field) -> u64 { self.inner.get_number_from_array_unchecked(array_index) } - fn get_string(self, key: [u8; KeyBytes]) -> Option> { + fn get_string(self, key: [u8; KeyBytes]) -> Option> { self.inner.get_string(key) } - fn get_string_unchecked(self, key: [u8; KeyBytes]) -> BoundedVec { + fn get_string_unchecked(self, key: [u8; KeyBytes]) -> BoundedVec { self.inner.get_string_unchecked(key) } - fn get_string_var(self, key: BoundedVec) -> Option> { + fn get_string_var(self, key: BoundedVec) -> Option> { self.inner.get_string_var(key) } - fn get_string_unchecked_var(self, key: BoundedVec) -> BoundedVec { + fn get_string_unchecked_var(self, key: BoundedVec) -> BoundedVec { self.inner.get_string_unchecked_var(key) } - fn get_string_from_array(self, array_index: Field) -> Option> { + fn get_string_from_array(self, array_index: Field) -> Option> { self.inner.get_string_from_array(array_index) } - fn get_string_from_array_unchecked(self, array_index: Field) -> BoundedVec { + fn get_string_from_array_unchecked(self, array_index: Field) -> BoundedVec { self.inner.get_string_from_array_unchecked(array_index) } - fn get_string_from_path( + fn get_string_from_path( self, keys: [BoundedVec; PathDepth] ) -> Option> { self.inner.get_string_from_path(keys) } - fn get_value(self, key: [u8; KeyBytes]) -> Option> { + fn get_value(self, key: [u8; KeyBytes]) -> Option> { self.inner.get_value(key) } - fn get_value_unchecked(self, key: [u8; KeyBytes]) -> crate::JSONValue { + fn get_value_unchecked(self, key: [u8; KeyBytes]) -> crate::JSONValue { self.inner.get_value_unchecked(key) } - fn get_value_var(self, key: BoundedVec) -> Option> { + fn get_value_var(self, key: BoundedVec) -> Option> { self.inner.get_value_var(key) } - fn get_value_unchecked_var(self, key: BoundedVec) -> crate::JSONValue { + fn get_value_unchecked_var(self, key: BoundedVec) -> crate::JSONValue { self.inner.get_value_unchecked_var(key) } - fn get_value_from_array(self, array_index: Field) -> Option> { + fn get_value_from_array(self, array_index: Field) -> Option> { self.inner.get_value_from_array(array_index) } - fn get_value_from_array_unchecked(self, array_index: Field) -> crate::JSONValue { + fn get_value_from_array_unchecked(self, array_index: Field) -> crate::JSONValue { self.inner.get_value_from_array_unchecked(array_index) } - fn get_value_from_path( + fn get_value_from_path( self, keys: [BoundedVec; PathDepth] ) -> Option> { self.inner.get_value_from_path(keys) } - fn key_exists(self, key: BoundedVec) -> bool { + fn key_exists(self, key: BoundedVec) -> bool { self.inner.key_exists(key) } - fn get_keys_at_root(self) -> BoundedVec, MaxNumKeys> { + fn get_keys_at_root(self) -> BoundedVec, MaxNumKeys> { self.inner.get_keys_at_root() } }