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