Skip to content

Commit 5bd38c9

Browse files
committed
make get functions public
1 parent 10146b0 commit 5bd38c9

File tree

6 files changed

+38
-38
lines changed

6 files changed

+38
-38
lines changed

src/get_array.nr

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
1414
/**
1515
* @brief if the root JSON is an array, return its length
1616
**/
17-
pub(crate) fn get_length(self) -> u32 {
17+
pub fn get_length(self) -> u32 {
1818
assert(self.layer_type_of_root == ARRAY_LAYER, "can only get length of an array type");
1919
let parent_entry: JSONEntry =
2020
self.json_entries_packed[self.root_index_in_transcript].into();
@@ -25,7 +25,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
2525
* @brief if the root JSON is an object, extract an array given by `key`
2626
* @description returns an Option<JSON> where, if the array exists, the JSON object will have the requested array as its root value
2727
**/
28-
pub(crate) fn get_array<let KeyBytes: u32>(self, key: [u8; KeyBytes]) -> Option<Self> {
28+
pub fn get_array<let KeyBytes: u32>(self, key: [u8; KeyBytes]) -> Option<Self> {
2929
assert(self.layer_type_of_root != ARRAY_LAYER, "cannot extract array elements via a key");
3030
let (exists, key_index) = self.key_exists_impl(key);
3131
let entry: JSONEntry = self.json_entries_packed[key_index].into();
@@ -51,7 +51,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
5151
* @brief if the root JSON is an object, extract an array given by `key`
5252
* @description will revert if the array does not exist
5353
**/
54-
pub(crate) fn get_array_unchecked<let KeyBytes: u32>(self, key: [u8; KeyBytes]) -> Self {
54+
pub fn get_array_unchecked<let KeyBytes: u32>(self, key: [u8; KeyBytes]) -> Self {
5555
assert(self.layer_type_of_root != ARRAY_LAYER, "cannot extract array elements via a key");
5656

5757
let (entry, key_index) = self.get_json_entry_unchecked_with_key_index(key);
@@ -69,7 +69,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
6969
/**
7070
* @brief same as `get_array` for where the key length may be less than KeyBytes
7171
**/
72-
pub(crate) fn get_array_var<let KeyBytes: u32>(
72+
pub fn get_array_var<let KeyBytes: u32>(
7373
self,
7474
key: BoundedVec<u8, KeyBytes>,
7575
) -> Option<Self> {
@@ -101,7 +101,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
101101
/**
102102
* @brief same as `get_array_unchecked` for where the key length may be less than KeyBytes
103103
**/
104-
pub(crate) fn get_array_unchecked_var<let KeyBytes: u32>(
104+
pub fn get_array_unchecked_var<let KeyBytes: u32>(
105105
self,
106106
key: BoundedVec<u8, KeyBytes>,
107107
) -> Self {
@@ -123,7 +123,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
123123
* @brief if the root JSON is an array, extract an array given by the position of the target in the source array
124124
* @description returns an Option<JSON> where, if the array exists, the JSON object will have the requested array as its root value
125125
**/
126-
pub(crate) fn get_array_from_array(self, array_index: Field) -> Option<Self> {
126+
pub fn get_array_from_array(self, array_index: Field) -> Option<Self> {
127127
assert(
128128
self.layer_type_of_root == ARRAY_LAYER,
129129
"can only acceess array elements from array",
@@ -160,7 +160,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
160160
* @brief if the root JSON is an array, extract an array given by the position of the target in the source array
161161
* @description will revert if the array does not exist
162162
**/
163-
pub(crate) fn get_array_from_array_unchecked(self, array_index: Field) -> Self {
163+
pub fn get_array_from_array_unchecked(self, array_index: Field) -> Self {
164164
assert(
165165
self.layer_type_of_root == ARRAY_LAYER,
166166
"can only acceess array elements from array",

src/get_literal.nr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
7373
* @brief if the root JSON is an object, extract a literal value given by `key`
7474
* @description returns an Option<JSONLiteral> which will be null if the literal does not exist
7575
**/
76-
pub(crate) fn get_literal<let KeyBytes: u32>(self, key: [u8; KeyBytes]) -> Option<JSONLiteral> {
76+
pub fn get_literal<let KeyBytes: u32>(self, key: [u8; KeyBytes]) -> Option<JSONLiteral> {
7777
assert(self.layer_type_of_root != ARRAY_LAYER, "cannot extract array elements via a key");
7878

7979
let (exists, entry) = self.get_json_entry(key);
@@ -95,7 +95,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
9595
* @brief if the root JSON is an object, extract a literal value given by `key`
9696
* @description will revert if the literal does not exist
9797
**/
98-
fn get_literal_unchecked<let KeyBytes: u32>(self, key: [u8; KeyBytes]) -> JSONLiteral {
98+
pub fn get_literal_unchecked<let KeyBytes: u32>(self, key: [u8; KeyBytes]) -> JSONLiteral {
9999
assert(self.layer_type_of_root != ARRAY_LAYER, "cannot extract array elements via a key");
100100

101101
let entry = self.get_json_entry_unchecked(key);
@@ -112,7 +112,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
112112
/**
113113
* @brief same as `get_literal` for where the key length may be less than KeyBytes
114114
**/
115-
fn get_literal_var<let KeyBytes: u32>(
115+
pub fn get_literal_var<let KeyBytes: u32>(
116116
self,
117117
key: BoundedVec<u8, KeyBytes>,
118118
) -> Option<JSONLiteral> {
@@ -136,7 +136,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
136136
/**
137137
* @brief same as `get_literal_unchecked` for where the key length may be less than KeyBytes
138138
**/
139-
fn get_literal_unchecked_var<let KeyBytes: u32>(
139+
pub fn get_literal_unchecked_var<let KeyBytes: u32>(
140140
self,
141141
key: BoundedVec<u8, KeyBytes>,
142142
) -> JSONLiteral {
@@ -193,7 +193,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
193193
* @brief if the root JSON is an array, extract a literal given by the position of the target in the source array
194194
* @description will revert if the literal does not exist
195195
**/
196-
fn get_literal_from_array_unchecked(self, array_index: Field) -> JSONLiteral {
196+
pub fn get_literal_from_array_unchecked(self, array_index: Field) -> JSONLiteral {
197197
assert(
198198
self.layer_type_of_root == ARRAY_LAYER,
199199
"can only acceess array elements from array",

src/get_number.nr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
5454
* @brief if the root JSON is an object, extract a numeric value given by `key`
5555
* @description returns an Option<u64> which will be null if the key does not exist
5656
**/
57-
pub(crate) fn get_number<let KeyBytes: u32>(self, key: [u8; KeyBytes]) -> Option<u64> {
57+
pub fn get_number<let KeyBytes: u32>(self, key: [u8; KeyBytes]) -> Option<u64> {
5858
let (exists, entry) = self.get_json_entry(key);
5959
assert(
6060
(entry.entry_type - NUMERIC_TOKEN as Field) * exists as Field == 0,
@@ -73,7 +73,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
7373
* @brief if the root JSON is an object, extract a u64 value given by `key`
7474
* @description will revert if the number does not exist
7575
**/
76-
fn get_number_unchecked<let KeyBytes: u32>(self, key: [u8; KeyBytes]) -> u64 {
76+
pub fn get_number_unchecked<let KeyBytes: u32>(self, key: [u8; KeyBytes]) -> u64 {
7777
let entry = self.get_json_entry_unchecked(key);
7878
assert(
7979
entry.entry_type == NUMERIC_TOKEN as Field,
@@ -87,7 +87,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
8787
/**
8888
* @brief same as `get_number` for where the key length may be less than KeyBytes
8989
**/
90-
fn get_number_var<let KeyBytes: u32>(self, key: BoundedVec<u8, KeyBytes>) -> Option<u64> {
90+
pub fn get_number_var<let KeyBytes: u32>(self, key: BoundedVec<u8, KeyBytes>) -> Option<u64> {
9191
let (exists, entry) = self.get_json_entry_var(key);
9292
assert(
9393
(entry.entry_type - NUMERIC_TOKEN as Field) * exists as Field == 0,
@@ -105,7 +105,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
105105
/**
106106
* @brief same as `get_number_unchecked` for where the key length may be less than KeyBytes
107107
**/
108-
fn get_number_unchecked_var<let KeyBytes: u32>(self, key: BoundedVec<u8, KeyBytes>) -> u64 {
108+
pub fn get_number_unchecked_var<let KeyBytes: u32>(self, key: BoundedVec<u8, KeyBytes>) -> u64 {
109109
let entry = self.get_json_entry_unchecked_var(key);
110110
assert(
111111
entry.entry_type == NUMERIC_TOKEN as Field,
@@ -120,7 +120,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
120120
* @brief if the root JSON is an array, extract a numeric value given by the position of the target in the source array
121121
* @description returns an Option<u64> which will be null if the number does not exist
122122
**/
123-
fn get_number_from_array(self, array_index: Field) -> Option<u64> {
123+
pub fn get_number_from_array(self, array_index: Field) -> Option<u64> {
124124
assert(
125125
self.layer_type_of_root == ARRAY_LAYER,
126126
"can only acceess array elements from array",
@@ -155,7 +155,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
155155
* @brief if the root JSON is an array, extract a numeric value given by the position of the target in the source array
156156
* @description will revert if the number does not exist
157157
**/
158-
fn get_number_from_array_unchecked(self, array_index: Field) -> u64 {
158+
pub fn get_number_from_array_unchecked(self, array_index: Field) -> u64 {
159159
assert(
160160
self.layer_type_of_root == ARRAY_LAYER,
161161
"can only acceess array elements from array",

src/get_object.nr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
1414
* @brief if the root JSON is an object, extract a child object given by `key`
1515
* @description returns an Option<JSON> where, if the object exists, the JSON object will have the requested object as its root value
1616
**/
17-
pub(crate) fn get_object<let KeyBytes: u32>(self, key: [u8; KeyBytes]) -> Option<Self> {
17+
pub fn get_object<let KeyBytes: u32>(self, key: [u8; KeyBytes]) -> Option<Self> {
1818
assert(self.layer_type_of_root != ARRAY_LAYER, "cannot extract array elements via a key");
1919

2020
let (exists, key_index) = self.key_exists_impl(key);
@@ -40,7 +40,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
4040
* @brief if the root JSON is an object, extract a child object given by `key`
4141
* @description will revert if the requested object does not exist
4242
**/
43-
pub(crate) fn get_object_unchecked<let KeyBytes: u32>(self, key: [u8; KeyBytes]) -> Self {
43+
pub fn get_object_unchecked<let KeyBytes: u32>(self, key: [u8; KeyBytes]) -> Self {
4444
assert(self.layer_type_of_root != ARRAY_LAYER, "cannot extract array elements via a key");
4545
let (entry, key_index) = self.get_json_entry_unchecked_with_key_index(key);
4646
let entry: JSONEntry = self.json_entries_packed[key_index].into();
@@ -60,7 +60,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
6060
/**
6161
* @brief same as `get_object` for where the key length may be less than KeyBytes
6262
**/
63-
pub(crate) fn get_object_var<let KeyBytes: u32>(
63+
pub fn get_object_var<let KeyBytes: u32>(
6464
self,
6565
key: BoundedVec<u8, KeyBytes>,
6666
) -> Option<Self> {
@@ -88,7 +88,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
8888
/**
8989
* @brief same as `get_object_unchecked` for where the key length may be less than KeyBytes
9090
**/
91-
pub(crate) fn get_object_unchecked_var<let KeyBytes: u32>(
91+
pub fn get_object_unchecked_var<let KeyBytes: u32>(
9292
self,
9393
key: BoundedVec<u8, KeyBytes>,
9494
) -> Self {
@@ -112,7 +112,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
112112
* @brief if the root JSON is an array, extract an object given by the position of the target in the source array
113113
* @description returns an Option<JSON> where, if the object exists, the JSON object will have the requested object as its root value
114114
**/
115-
pub(crate) fn get_object_from_array(self, array_index: Field) -> Option<Self> {
115+
pub fn get_object_from_array(self, array_index: Field) -> Option<Self> {
116116
assert(
117117
self.layer_type_of_root == ARRAY_LAYER,
118118
"can only acceess array elements from array",
@@ -150,7 +150,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
150150
* @brief if the root JSON is an array, extract an object given by the position of the target in the source array
151151
* @description will revert if the object does not exist
152152
**/
153-
pub(crate) fn get_object_from_array_unchecked(self, array_index: Field) -> Self {
153+
pub fn get_object_from_array_unchecked(self, array_index: Field) -> Self {
154154
assert(
155155
self.layer_type_of_root == ARRAY_LAYER,
156156
"can only acceess array elements from array",

src/get_string.nr

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
101101
* @description returns an Option<BoundedVec> which will be null if the key does not exist
102102
* @note the `StringBytes` parameter defines the maximum allowable length of the returned string
103103
**/
104-
pub(crate) fn get_string<let KeyBytes: u32, let StringBytes: u32>(
104+
pub fn get_string<let KeyBytes: u32, let StringBytes: u32>(
105105
self,
106106
key: [u8; KeyBytes],
107107
) -> Option<BoundedVec<u8, StringBytes>> {
@@ -128,7 +128,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
128128
* @description will revert if the string does not exist
129129
* @note the `StringBytes` parameter defines the maximum allowable length of the returned string
130130
**/
131-
pub(crate) fn get_string_unchecked<let KeyBytes: u32, let StringBytes: u32>(
131+
pub fn get_string_unchecked<let KeyBytes: u32, let StringBytes: u32>(
132132
self,
133133
key: [u8; KeyBytes],
134134
) -> BoundedVec<u8, StringBytes> {
@@ -147,7 +147,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
147147
/**
148148
* @brief same as `get_string` for where the key length may be less than KeyBytes
149149
**/
150-
pub(crate) fn get_string_var<let KeyBytes: u32, let StringBytes: u32>(
150+
pub fn get_string_var<let KeyBytes: u32, let StringBytes: u32>(
151151
self,
152152
key: BoundedVec<u8, KeyBytes>,
153153
) -> Option<BoundedVec<u8, StringBytes>> {
@@ -171,7 +171,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
171171
/**
172172
* @brief same as `get_string_unchecked` for where the key length may be less than KeyBytes
173173
**/
174-
pub(crate) fn get_string_unchecked_var<let KeyBytes: u32, let StringBytes: u32>(
174+
pub fn get_string_unchecked_var<let KeyBytes: u32, let StringBytes: u32>(
175175
self,
176176
key: BoundedVec<u8, KeyBytes>,
177177
) -> BoundedVec<u8, StringBytes> {
@@ -191,7 +191,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
191191
* @brief if the root JSON is an array, extract a string given by the position of the target in the source array
192192
* @description returns an Option<BoundedVec> which will be null if the string does not exist
193193
**/
194-
pub(crate) fn get_string_from_array<let StringBytes: u32>(
194+
pub fn get_string_from_array<let StringBytes: u32>(
195195
self,
196196
array_index: Field,
197197
) -> Option<BoundedVec<u8, StringBytes>> {
@@ -231,7 +231,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
231231
* @brief if the root JSON is an array, extract a string given by the position of the target in the source array
232232
* @description will revert if the string does not exist
233233
**/
234-
pub(crate) fn get_string_from_array_unchecked<let StringBytes: u32>(
234+
pub fn get_string_from_array_unchecked<let StringBytes: u32>(
235235
self,
236236
array_index: Field,
237237
) -> BoundedVec<u8, StringBytes> {
@@ -264,7 +264,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
264264
/**
265265
* @brief if the root JSON is an object, get a nested string out of the JSON, which may be several keys deep
266266
**/
267-
pub(crate) fn get_string_from_path<let KeyBytes: u32, let StringBytes: u32, let PathDepth: u32>(
267+
pub fn get_string_from_path<let KeyBytes: u32, let StringBytes: u32, let PathDepth: u32>(
268268
self,
269269
keys: [BoundedVec<u8, KeyBytes>; PathDepth],
270270
) -> Option<BoundedVec<u8, StringBytes>> {
@@ -290,7 +290,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
290290
* @description returns an Option<JSONValue> which will be null if the key does not exist
291291
* @note the `StringBytes` parameter defines the maximum allowable length of the returned value
292292
**/
293-
pub(crate) fn get_value<let KeyBytes: u32, let StringBytes: u32>(
293+
pub fn get_value<let KeyBytes: u32, let StringBytes: u32>(
294294
self,
295295
key: [u8; KeyBytes],
296296
) -> Option<JSONValue<StringBytes>> {
@@ -314,7 +314,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
314314
* @description will revert if the string does not exist
315315
* @note the `StringBytes` parameter defines the maximum allowable length of the returned value
316316
**/
317-
pub(crate) fn get_value_unchecked<let KeyBytes: u32, let StringBytes: u32>(
317+
pub fn get_value_unchecked<let KeyBytes: u32, let StringBytes: u32>(
318318
self,
319319
key: [u8; KeyBytes],
320320
) -> JSONValue<StringBytes> {
@@ -353,7 +353,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
353353
/**
354354
* @brief same as `get_value_unchecked` for where the key length may be less than KeyBytes
355355
**/
356-
pub(crate) fn get_value_unchecked_var<let KeyBytes: u32, let StringBytes: u32>(
356+
pub fn get_value_unchecked_var<let KeyBytes: u32, let StringBytes: u32>(
357357
self,
358358
key: BoundedVec<u8, KeyBytes>,
359359
) -> JSONValue<StringBytes> {
@@ -371,7 +371,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
371371
* @brief if the root JSON is an array, extract a value given by the position of the target in the source array
372372
* @description returns an Option<BoundedVec> which will be null if the value does not exist
373373
**/
374-
pub(crate) fn get_value_from_array<let StringBytes: u32>(
374+
pub fn get_value_from_array<let StringBytes: u32>(
375375
self,
376376
array_index: Field,
377377
) -> Option<JSONValue<StringBytes>> {
@@ -416,7 +416,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
416416
* @brief if the root JSON is an array, extract a value given by the position of the target in the source array
417417
* @description will revert if the value does not exist
418418
**/
419-
pub(crate) fn get_value_from_array_unchecked<let StringBytes: u32>(
419+
pub fn get_value_from_array_unchecked<let StringBytes: u32>(
420420
self,
421421
array_index: Field,
422422
) -> JSONValue<StringBytes> {
@@ -449,7 +449,7 @@ impl<let NumBytes: u32, let NumPackedFields: u32, let MaxNumTokens: u32, let Max
449449
/**
450450
* @brief if the root JSON is an object, get a nested value out of the JSON, which may be several keys deep
451451
**/
452-
pub(crate) fn get_value_from_path<let KeyBytes: u32, let StringBytes: u32, let PathDepth: u32>(
452+
pub fn get_value_from_path<let KeyBytes: u32, let StringBytes: u32, let PathDepth: u32>(
453453
self,
454454
keys: [BoundedVec<u8, KeyBytes>; PathDepth],
455455
) -> Option<JSONValue<StringBytes>> {

0 commit comments

Comments
 (0)