@@ -6,20 +6,24 @@ use std::marker::PhantomData;
66
77/// Iterates over the whole result, returning rows.
88#[ derive( Debug ) ]
9- pub struct RowIterator < ' frame > {
10- specs : & ' frame [ ColumnSpec < ' frame > ] ,
9+ pub struct RowIterator < ' frame , ' metadata > {
10+ specs : & ' metadata [ ColumnSpec < ' metadata > ] ,
1111 remaining : usize ,
1212 slice : FrameSlice < ' frame > ,
1313}
1414
15- impl < ' frame > RowIterator < ' frame > {
15+ impl < ' frame , ' metadata > RowIterator < ' frame , ' metadata > {
1616 /// Creates a new iterator over rows from a serialized response.
1717 ///
1818 /// - `remaining` - number of the remaining rows in the serialized response,
1919 /// - `specs` - information about columns of the serialized response,
2020 /// - `slice` - a [FrameSlice] that points to the serialized rows data.
2121 #[ inline]
22- pub fn new ( remaining : usize , specs : & ' frame [ ColumnSpec ] , slice : FrameSlice < ' frame > ) -> Self {
22+ pub fn new (
23+ remaining : usize ,
24+ specs : & ' metadata [ ColumnSpec < ' metadata > ] ,
25+ slice : FrameSlice < ' frame > ,
26+ ) -> Self {
2327 Self {
2428 specs,
2529 remaining,
@@ -29,7 +33,7 @@ impl<'frame> RowIterator<'frame> {
2933
3034 /// Returns information about the columns of rows that are iterated over.
3135 #[ inline]
32- pub fn specs ( & self ) -> & ' frame [ ColumnSpec ] {
36+ pub fn specs ( & self ) -> & ' metadata [ ColumnSpec < ' metadata > ] {
3337 self . specs
3438 }
3539
@@ -41,8 +45,8 @@ impl<'frame> RowIterator<'frame> {
4145 }
4246}
4347
44- impl < ' frame > Iterator for RowIterator < ' frame > {
45- type Item = Result < ColumnIterator < ' frame , ' frame > , DeserializationError > ;
48+ impl < ' frame , ' metadata > Iterator for RowIterator < ' frame , ' metadata > {
49+ type Item = Result < ColumnIterator < ' frame , ' metadata > , DeserializationError > ;
4650
4751 #[ inline]
4852 fn next ( & mut self ) -> Option < Self :: Item > {
@@ -78,20 +82,20 @@ impl<'frame> Iterator for RowIterator<'frame> {
7882/// A typed version of [RowIterator] which deserializes the rows before
7983/// returning them.
8084#[ derive( Debug ) ]
81- pub struct TypedRowIterator < ' frame , R > {
82- inner : RowIterator < ' frame > ,
85+ pub struct TypedRowIterator < ' frame , ' metadata , R > {
86+ inner : RowIterator < ' frame , ' metadata > ,
8387 _phantom : PhantomData < R > ,
8488}
8589
86- impl < ' frame , R > TypedRowIterator < ' frame , R >
90+ impl < ' frame , ' metadata , R > TypedRowIterator < ' frame , ' metadata , R >
8791where
88- R : DeserializeRow < ' frame , ' frame > ,
92+ R : DeserializeRow < ' frame , ' metadata > ,
8993{
9094 /// Creates a new [TypedRowIterator] from given [RowIterator].
9195 ///
9296 /// Calls `R::type_check` and fails if the type check fails.
9397 #[ inline]
94- pub fn new ( raw : RowIterator < ' frame > ) -> Result < Self , TypeCheckError > {
98+ pub fn new ( raw : RowIterator < ' frame , ' metadata > ) -> Result < Self , TypeCheckError > {
9599 R :: type_check ( raw. specs ( ) ) ?;
96100 Ok ( Self {
97101 inner : raw,
@@ -101,7 +105,7 @@ where
101105
102106 /// Returns information about the columns of rows that are iterated over.
103107 #[ inline]
104- pub fn specs ( & self ) -> & ' frame [ ColumnSpec ] {
108+ pub fn specs ( & self ) -> & ' metadata [ ColumnSpec < ' metadata > ] {
105109 self . inner . specs ( )
106110 }
107111
@@ -113,9 +117,9 @@ where
113117 }
114118}
115119
116- impl < ' frame , R > Iterator for TypedRowIterator < ' frame , R >
120+ impl < ' frame , ' metadata , R > Iterator for TypedRowIterator < ' frame , ' metadata , R >
117121where
118- R : DeserializeRow < ' frame , ' frame > ,
122+ R : DeserializeRow < ' frame , ' metadata > ,
119123{
120124 type Item = Result < R , DeserializationError > ;
121125
@@ -179,7 +183,7 @@ mod tests {
179183 let raw_data = serialize_cells ( [ Some ( CELL1 ) , Some ( CELL2 ) , Some ( CELL2 ) , Some ( CELL1 ) ] ) ;
180184 let specs = [ spec ( "b1" , ColumnType :: Blob ) , spec ( "b2" , ColumnType :: Blob ) ] ;
181185 let iter = RowIterator :: new ( 2 , & specs, FrameSlice :: new ( & raw_data) ) ;
182- let mut iter = TypedRowIterator :: < ' _ , ( & [ u8 ] , Vec < u8 > ) > :: new ( iter) . unwrap ( ) ;
186+ let mut iter = TypedRowIterator :: < ' _ , ' _ , ( & [ u8 ] , Vec < u8 > ) > :: new ( iter) . unwrap ( ) ;
183187
184188 let ( c11, c12) = iter. next ( ) . unwrap ( ) . unwrap ( ) ;
185189 assert_eq ! ( c11, CELL1 ) ;
@@ -197,6 +201,6 @@ mod tests {
197201 let raw_data = Bytes :: new ( ) ;
198202 let specs = [ spec ( "b1" , ColumnType :: Blob ) , spec ( "b2" , ColumnType :: Blob ) ] ;
199203 let iter = RowIterator :: new ( 0 , & specs, FrameSlice :: new ( & raw_data) ) ;
200- assert ! ( TypedRowIterator :: <' _, ( i32 , i64 ) >:: new( iter) . is_err( ) ) ;
204+ assert ! ( TypedRowIterator :: <' _, ' _ , ( i32 , i64 ) >:: new( iter) . is_err( ) ) ;
201205 }
202206}
0 commit comments