@@ -20,26 +20,41 @@ use super::*;
2020impl < N : Network > FinalizeType < N > {
2121 /// Returns the number of bits of a finalize type.
2222 /// Note. The plaintext variant is assumed to be an argument of a `Future` and this does not have a "raw" serialization.
23- pub fn future_size_in_bits < F0 , F1 > ( locator : & Locator < N > , get_struct : & F0 , get_future : & F1 ) -> Result < usize >
23+ pub fn future_size_in_bits < F0 , F1 , F2 > (
24+ locator : & Locator < N > ,
25+ get_struct : & F0 ,
26+ get_external_struct : & F1 ,
27+ get_future : & F2 ,
28+ ) -> Result < usize >
2429 where
2530 F0 : Fn ( & Identifier < N > ) -> Result < StructType < N > > ,
26- F1 : Fn ( & Locator < N > ) -> Result < Vec < FinalizeType < N > > > ,
31+ F1 : Fn ( & Locator < N > ) -> Result < StructType < N > > ,
32+ F2 : Fn ( & Locator < N > ) -> Result < Vec < FinalizeType < N > > > ,
2733 {
28- FinalizeType :: Future ( * locator) . size_in_bits_internal ( get_struct, get_future, 0 )
34+ FinalizeType :: Future ( * locator) . size_in_bits_internal ( get_struct, get_external_struct , get_future, 0 )
2935 }
3036
3137 /// A helper function to determine the number of bits of a plaintext type, while tracking the depth of the data.
3238 /// Note. The plaintext variant is assumed to be an argument of a `Future` and thus does not have a "raw" serialization.
33- fn size_in_bits_internal < F0 , F1 > ( & self , get_struct : & F0 , get_future : & F1 , depth : usize ) -> Result < usize >
39+ fn size_in_bits_internal < F0 , F1 , F2 > (
40+ & self ,
41+ get_struct : & F0 ,
42+ get_external_struct : & F1 ,
43+ get_future : & F2 ,
44+ depth : usize ,
45+ ) -> Result < usize >
3446 where
3547 F0 : Fn ( & Identifier < N > ) -> Result < StructType < N > > ,
36- F1 : Fn ( & Locator < N > ) -> Result < Vec < FinalizeType < N > > > ,
48+ F1 : Fn ( & Locator < N > ) -> Result < StructType < N > > ,
49+ F2 : Fn ( & Locator < N > ) -> Result < Vec < FinalizeType < N > > > ,
3750 {
3851 // Ensure that the depth is within the maximum limit.
3952 ensure ! ( depth <= N :: MAX_DATA_DEPTH , "Finalize type depth exceeds maximum limit: {}" , N :: MAX_DATA_DEPTH ) ;
4053
4154 match self {
42- Self :: Plaintext ( plaintext_type) => plaintext_type. size_in_bits_internal ( get_struct, depth) ,
55+ Self :: Plaintext ( plaintext_type) => {
56+ plaintext_type. size_in_bits_internal ( get_struct, get_external_struct, depth)
57+ }
4358 Self :: Future ( locator) => {
4459 // Initialize the size in bits.
4560 let mut size = 0usize ;
@@ -79,7 +94,12 @@ impl<N: Network> FinalizeType<N> {
7994
8095 // Account for the argument bits.
8196 size = size
82- . checked_add ( argument. size_in_bits_internal ( get_struct, get_future, depth + 1 ) ?)
97+ . checked_add ( argument. size_in_bits_internal (
98+ get_struct,
99+ get_external_struct,
100+ get_future,
101+ depth + 1 ,
102+ ) ?)
83103 . ok_or ( anyhow ! ( "`size_in_bits` overflowed" ) ) ?;
84104 }
85105
@@ -89,11 +109,17 @@ impl<N: Network> FinalizeType<N> {
89109 }
90110
91111 /// Returns the number of raw bits of a finlaize type.
92- pub fn future_size_in_bits_raw < F0 , F1 > ( locator : & Locator < N > , get_struct : & F0 , get_future : & F1 ) -> Result < usize >
112+ pub fn future_size_in_bits_raw < F0 , F1 , F2 > (
113+ locator : & Locator < N > ,
114+ get_struct : & F0 ,
115+ get_external_struct : & F1 ,
116+ get_future : & F2 ,
117+ ) -> Result < usize >
93118 where
94119 F0 : Fn ( & Identifier < N > ) -> Result < StructType < N > > ,
95- F1 : Fn ( & Locator < N > ) -> Result < Vec < FinalizeType < N > > > ,
120+ F1 : Fn ( & Locator < N > ) -> Result < StructType < N > > ,
121+ F2 : Fn ( & Locator < N > ) -> Result < Vec < FinalizeType < N > > > ,
96122 {
97- Self :: future_size_in_bits ( locator, get_struct, get_future)
123+ Self :: future_size_in_bits ( locator, get_struct, get_external_struct , get_future)
98124 }
99125}
0 commit comments