@@ -100,7 +100,7 @@ impl Client {
100100 /// .raw_batch(["CREATE TABLE t(id)", "INSERT INTO t VALUES (42)"]);
101101 /// # }
102102 /// ```
103- pub fn raw_batch (
103+ pub async fn raw_batch (
104104 & self ,
105105 stmts : impl IntoIterator < Item = impl Into < Statement > > ,
106106 ) -> Result < BatchResult > {
@@ -116,7 +116,7 @@ impl Client {
116116 . map ( libsql:: Value :: from)
117117 . collect :: < Vec < _ > > ( )
118118 . into ( ) ;
119- let stmt = self . conn . prepare ( sql_string) ?;
119+ let stmt = self . conn . prepare ( sql_string) . await ?;
120120 let cols: Vec < Col > = stmt
121121 . columns ( )
122122 . into_iter ( )
@@ -125,7 +125,7 @@ impl Client {
125125 } )
126126 . collect ( ) ;
127127 let mut rows = Vec :: new ( ) ;
128- let input_rows = match stmt. query ( & params) {
128+ let mut input_rows = match stmt. query ( & params) . await {
129129 Ok ( rows) => rows,
130130 Err ( e) => {
131131 step_results. push ( None ) ;
@@ -179,15 +179,15 @@ impl Client {
179179 ///
180180 /// # Arguments
181181 /// * `stmts` - SQL statements
182- pub fn batch (
182+ pub async fn batch (
183183 & self ,
184184 stmts : impl IntoIterator < Item = impl Into < Statement > + Send > + Send ,
185185 ) -> Result < Vec < ResultSet > > {
186186 let batch_results = self . raw_batch (
187187 std:: iter:: once ( Statement :: new ( "BEGIN" ) )
188188 . chain ( stmts. into_iter ( ) . map ( |s| s. into ( ) ) )
189189 . chain ( std:: iter:: once ( Statement :: new ( "END" ) ) ) ,
190- ) ?;
190+ ) . await ?;
191191 let step_error: Option < proto:: Error > = batch_results
192192 . step_errors
193193 . into_iter ( )
@@ -214,24 +214,24 @@ impl Client {
214214
215215 /// # Arguments
216216 /// * `stmt` - the SQL statement
217- pub fn execute ( & self , stmt : impl Into < Statement > + Send ) -> Result < ResultSet > {
218- let results = self . raw_batch ( std:: iter:: once ( stmt) ) ?;
217+ pub async fn execute ( & self , stmt : impl Into < Statement > + Send ) -> Result < ResultSet > {
218+ let results = self . raw_batch ( std:: iter:: once ( stmt) ) . await ?;
219219 match ( results. step_results . first ( ) , results. step_errors . first ( ) ) {
220220 ( Some ( Some ( result) ) , Some ( None ) ) => Ok ( ResultSet :: from ( result. clone ( ) ) ) ,
221221 ( Some ( None ) , Some ( Some ( err) ) ) => Err ( Error :: Misuse ( err. message . clone ( ) ) ) ,
222222 _ => unreachable ! ( ) ,
223223 }
224224 }
225225
226- pub fn execute_in_transaction ( & self , _tx_id : u64 , stmt : Statement ) -> Result < ResultSet > {
227- self . execute ( stmt)
226+ pub async fn execute_in_transaction ( & self , _tx_id : u64 , stmt : Statement ) -> Result < ResultSet > {
227+ self . execute ( stmt) . await
228228 }
229229
230- pub fn commit_transaction ( & self , _tx_id : u64 ) -> Result < ( ) > {
231- self . execute ( "COMMIT" ) . map ( |_| ( ) )
230+ pub async fn commit_transaction ( & self , _tx_id : u64 ) -> Result < ( ) > {
231+ self . execute ( "COMMIT" ) . await . map ( |_| ( ) )
232232 }
233233
234- pub fn rollback_transaction ( & self , _tx_id : u64 ) -> Result < ( ) > {
235- self . execute ( "ROLLBACK" ) . map ( |_| ( ) )
234+ pub async fn rollback_transaction ( & self , _tx_id : u64 ) -> Result < ( ) > {
235+ self . execute ( "ROLLBACK" ) . await . map ( |_| ( ) )
236236 }
237237}
0 commit comments