@@ -37,7 +37,29 @@ impl<N: Network> ArrayType<N> {
3737 matches ! ( self . next_element_type( ) , PlaintextType :: Literal ( LiteralType :: Boolean ) )
3838 }
3939
40- /// Returns `true` if the record contains an array type with a size that exceeds the given maximum.
40+ /// Returns `true` if the `ArrayType` contains a string type.
41+ pub fn contains_string_type ( & self ) -> bool {
42+ // Initialize depth counter and current array type.
43+ let mut array_type = self ;
44+
45+ // Check nested array types up to the maximum data depth.
46+ for _ in 0 ..=N :: MAX_DATA_DEPTH {
47+ // Check if the current element type is a string type.
48+ if array_type. next_element_type ( ) . contains_string_type ( ) {
49+ return true ;
50+ }
51+ // If the next element is an array, continue to the next depth. Otherwise, we can stop checking.
52+ if let PlaintextType :: Array ( next) = array_type. next_element_type ( ) {
53+ array_type = next;
54+ } else {
55+ return false ;
56+ }
57+ }
58+ // If we reach here, it means we've exceeded the maximum depth without finding a non-array type.
59+ true
60+ }
61+
62+ /// Returns `true` if the `ArrayType` contains an array type with a size that exceeds the given maximum.
4163 pub fn exceeds_max_array_size ( & self , max_array_size : u32 ) -> bool {
4264 // Initialize depth counter and current array type.
4365 let mut array_type = self ;
@@ -48,7 +70,7 @@ impl<N: Network> ArrayType<N> {
4870 if * * array_type. length ( ) > max_array_size {
4971 return true ;
5072 }
51- // If the next eleemtn is an array, continue to the next depth. Otherwise, we can stop checking.
73+ // If the next element is an array, continue to the next depth. Otherwise, we can stop checking.
5274 if let PlaintextType :: Array ( next) = array_type. next_element_type ( ) {
5375 array_type = next;
5476 } else {
0 commit comments