@@ -604,14 +604,13 @@ impl Statement {
604604 let column_name = result. column_name ( i) . unwrap ( ) . to_string ( ) ;
605605 column_names. push ( std:: ffi:: CString :: new ( column_name) . unwrap ( ) ) ;
606606 }
607- let iter = RowsIterator :: new (
607+ Ok ( RowsIterator :: new (
608608 Arc :: new ( tokio:: sync:: Mutex :: new ( result) ) ,
609609 column_names,
610610 safe_ints,
611611 raw,
612612 pluck,
613- ) ?;
614- Ok ( iter)
613+ ) )
615614 } )
616615 }
617616
@@ -636,7 +635,9 @@ impl Statement {
636635 let rows = stmt. query ( params) . await . map_err ( Error :: from) ?;
637636 let mut column_names = Vec :: new ( ) ;
638637 for i in 0 ..rows. column_count ( ) {
639- column_names. push ( std:: ffi:: CString :: new ( rows. column_name ( i) . unwrap ( ) . to_string ( ) ) . unwrap ( ) ) ;
638+ column_names. push (
639+ std:: ffi:: CString :: new ( rows. column_name ( i) . unwrap ( ) . to_string ( ) ) . unwrap ( ) ,
640+ ) ;
640641 }
641642 Ok :: < _ , napi:: Error > ( ( rows, column_names) )
642643 } ;
@@ -727,7 +728,9 @@ impl Statement {
727728 let mut rows = stmt. query ( params) . await . map_err ( Error :: from) ?;
728729 let mut column_names = Vec :: new ( ) ;
729730 for i in 0 ..rows. column_count ( ) {
730- column_names. push ( std:: ffi:: CString :: new ( rows. column_name ( i) . unwrap ( ) . to_string ( ) ) . unwrap ( ) ) ;
731+ column_names. push (
732+ std:: ffi:: CString :: new ( rows. column_name ( i) . unwrap ( ) . to_string ( ) ) . unwrap ( ) ,
733+ ) ;
731734 }
732735 let row = rows. next ( ) . await . map_err ( Error :: from) ?;
733736 let duration = start. elapsed ( ) . as_secs_f64 ( ) ;
@@ -737,8 +740,9 @@ impl Statement {
737740 let js_array = map_row_raw ( & env, & column_names, & row, safe_ints, pluck) ?;
738741 Ok ( js_array. into_unknown ( ) )
739742 } else {
740- let mut js_object = map_row_object ( & env, & column_names, & row, safe_ints, pluck) ?
741- . coerce_to_object ( ) ?;
743+ let mut js_object =
744+ map_row_object ( & env, & column_names, & row, safe_ints, pluck) ?
745+ . coerce_to_object ( ) ?;
742746 let mut metadata = env. create_object ( ) ?;
743747 let js_duration = env. create_double ( duration) ?;
744748 metadata. set_named_property ( "duration" , js_duration) ?;
@@ -775,6 +779,7 @@ impl Statement {
775779 }
776780}
777781
782+ /// A raw iterator over rows. The JavaScript layer wraps this in a iterable.
778783#[ napi]
779784pub struct RowsIterator {
780785 rows : Arc < tokio:: sync:: Mutex < libsql:: Rows > > ,
@@ -792,15 +797,14 @@ impl RowsIterator {
792797 safe_ints : bool ,
793798 raw : bool ,
794799 pluck : bool ,
795- ) -> Result < Self > {
796- let iter = RowsIterator {
800+ ) -> Self {
801+ Self {
797802 rows,
798803 column_names,
799804 safe_ints,
800805 raw,
801806 pluck,
802- } ;
803- Ok ( iter)
807+ }
804808 }
805809
806810 #[ napi]
@@ -817,6 +821,7 @@ impl RowsIterator {
817821 }
818822}
819823
824+ /// Retrieve next row from an iterator synchronously. Needed for better-sqlite3 API compatibility.
820825#[ napi]
821826pub fn iterator_next_sync ( iter : & RowsIterator ) -> Result < Record > {
822827 let rt = runtime ( ) ?;
@@ -837,7 +842,14 @@ impl Record {
837842 #[ napi( getter) ]
838843 pub fn value ( & self , env : Env ) -> napi:: Result < napi:: JsUnknown > {
839844 if let Some ( row) = & self . row {
840- Ok ( map_row ( & env, & self . column_names , & row, self . safe_ints , self . raw , self . pluck ) ?)
845+ Ok ( map_row (
846+ & env,
847+ & self . column_names ,
848+ & row,
849+ self . safe_ints ,
850+ self . raw ,
851+ self . pluck ,
852+ ) ?)
841853 } else {
842854 Ok ( env. get_null ( ) ?. into_unknown ( ) )
843855 }
0 commit comments