@@ -277,7 +277,7 @@ impl<'a: 'b, 'b> From<&'a BatchStatement>
277
277
}
278
278
279
279
/// A batch with all of its statements bound to values
280
- pub ( crate ) struct BoundBatch {
280
+ pub struct BoundBatch {
281
281
pub ( crate ) config : StatementConfig ,
282
282
batch_type : BatchType ,
283
283
pub ( crate ) buffer : Vec < u8 > ,
@@ -287,6 +287,13 @@ pub(crate) struct BoundBatch {
287
287
}
288
288
289
289
impl BoundBatch {
290
+ pub fn new ( batch_type : BatchType ) -> Self {
291
+ Self {
292
+ batch_type,
293
+ ..Default :: default ( )
294
+ }
295
+ }
296
+
290
297
#[ allow( clippy:: result_large_err) ]
291
298
pub ( crate ) fn from_batch (
292
299
batch : & Batch ,
@@ -295,14 +302,12 @@ impl BoundBatch {
295
302
let mut bound_batch = BoundBatch {
296
303
config : batch. config . clone ( ) ,
297
304
batch_type : batch. batch_type ,
298
- prepared : HashMap :: new ( ) ,
299
- buffer : vec ! [ ] ,
300
- first_prepared : None ,
301
305
statements_len : batch. statements . len ( ) . try_into ( ) . map_err ( |_| {
302
306
ExecutionError :: BadQuery ( BadQuery :: TooManyQueriesInBatchStatement (
303
307
batch. statements . len ( ) ,
304
308
) )
305
309
} ) ?,
310
+ ..Default :: default ( )
306
311
} ;
307
312
308
313
let mut values = values. batch_values_iter ( ) ;
@@ -384,17 +389,17 @@ impl BoundBatch {
384
389
}
385
390
386
391
/// Borrows the execution profile handle associated with this batch.
387
- pub ( crate ) fn get_execution_profile_handle ( & self ) -> Option < & ExecutionProfileHandle > {
392
+ pub fn get_execution_profile_handle ( & self ) -> Option < & ExecutionProfileHandle > {
388
393
self . config . execution_profile_handle . as_ref ( )
389
394
}
390
395
391
396
/// Gets the default timestamp for this batch in microseconds.
392
- pub ( crate ) fn get_timestamp ( & self ) -> Option < i64 > {
397
+ pub fn get_timestamp ( & self ) -> Option < i64 > {
393
398
self . config . timestamp
394
399
}
395
400
396
401
/// Gets type of batch.
397
- pub ( crate ) fn get_type ( & self ) -> BatchType {
402
+ pub fn get_type ( & self ) -> BatchType {
398
403
self . batch_type
399
404
}
400
405
@@ -453,6 +458,19 @@ fn serialize_statement<T>(
453
458
Ok ( Some ( res) )
454
459
}
455
460
461
+ impl Default for BoundBatch {
462
+ fn default ( ) -> Self {
463
+ Self {
464
+ config : StatementConfig :: default ( ) ,
465
+ batch_type : BatchType :: Logged ,
466
+ buffer : Vec :: new ( ) ,
467
+ prepared : HashMap :: new ( ) ,
468
+ first_prepared : None ,
469
+ statements_len : 0 ,
470
+ }
471
+ }
472
+ }
473
+
456
474
fn counts_mismatch_err ( n_value_lists : usize , n_statements : u16 ) -> BatchSerializationError {
457
475
BatchSerializationError :: ValuesAndStatementsLengthMismatch {
458
476
n_value_lists,
0 commit comments