@@ -249,7 +249,7 @@ impl<'a: 'b, 'b> From<&'a BatchStatement>
249
249
}
250
250
251
251
/// A batch with all of its statements bound to values
252
- pub ( crate ) struct BoundBatch {
252
+ pub struct BoundBatch {
253
253
pub ( crate ) config : StatementConfig ,
254
254
batch_type : BatchType ,
255
255
pub ( crate ) buffer : Vec < u8 > ,
@@ -259,6 +259,13 @@ pub(crate) struct BoundBatch {
259
259
}
260
260
261
261
impl BoundBatch {
262
+ pub fn new ( batch_type : BatchType ) -> Self {
263
+ Self {
264
+ batch_type,
265
+ ..Default :: default ( )
266
+ }
267
+ }
268
+
262
269
#[ allow( clippy:: result_large_err) ]
263
270
pub ( crate ) fn from_batch (
264
271
batch : & Batch ,
@@ -267,14 +274,12 @@ impl BoundBatch {
267
274
let mut bound_batch = BoundBatch {
268
275
config : batch. config . clone ( ) ,
269
276
batch_type : batch. batch_type ,
270
- prepared : HashMap :: new ( ) ,
271
- buffer : vec ! [ ] ,
272
- first_prepared : None ,
273
277
statements_len : batch. statements . len ( ) . try_into ( ) . map_err ( |_| {
274
278
ExecutionError :: BadQuery ( BadQuery :: TooManyQueriesInBatchStatement (
275
279
batch. statements . len ( ) ,
276
280
) )
277
281
} ) ?,
282
+ ..Default :: default ( )
278
283
} ;
279
284
280
285
let mut values = values. batch_values_iter ( ) ;
@@ -356,17 +361,17 @@ impl BoundBatch {
356
361
}
357
362
358
363
/// Borrows the execution profile handle associated with this batch.
359
- pub ( crate ) fn get_execution_profile_handle ( & self ) -> Option < & ExecutionProfileHandle > {
364
+ pub fn get_execution_profile_handle ( & self ) -> Option < & ExecutionProfileHandle > {
360
365
self . config . execution_profile_handle . as_ref ( )
361
366
}
362
367
363
368
/// Gets the default timestamp for this batch in microseconds.
364
- pub ( crate ) fn get_timestamp ( & self ) -> Option < i64 > {
369
+ pub fn get_timestamp ( & self ) -> Option < i64 > {
365
370
self . config . timestamp
366
371
}
367
372
368
373
/// Gets type of batch.
369
- pub ( crate ) fn get_type ( & self ) -> BatchType {
374
+ pub fn get_type ( & self ) -> BatchType {
370
375
self . batch_type
371
376
}
372
377
@@ -425,6 +430,19 @@ fn serialize_statement<T>(
425
430
Ok ( Some ( res) )
426
431
}
427
432
433
+ impl Default for BoundBatch {
434
+ fn default ( ) -> Self {
435
+ Self {
436
+ config : StatementConfig :: default ( ) ,
437
+ batch_type : BatchType :: Logged ,
438
+ buffer : Vec :: new ( ) ,
439
+ prepared : HashMap :: new ( ) ,
440
+ first_prepared : None ,
441
+ statements_len : 0 ,
442
+ }
443
+ }
444
+ }
445
+
428
446
fn counts_mismatch_err ( n_value_lists : usize , n_statements : u16 ) -> BatchSerializationError {
429
447
BatchSerializationError :: ValuesAndStatementsLengthMismatch {
430
448
n_value_lists,
0 commit comments