@@ -225,7 +225,7 @@ impl<'a: 'b, 'b> From<&'a BatchStatement>
225
225
}
226
226
227
227
/// A batch with all of its statements bound to values
228
- pub ( crate ) struct BoundBatch {
228
+ pub struct BoundBatch {
229
229
pub ( crate ) config : StatementConfig ,
230
230
batch_type : BatchType ,
231
231
pub ( crate ) buffer : Vec < u8 > ,
@@ -235,21 +235,26 @@ pub(crate) struct BoundBatch {
235
235
}
236
236
237
237
impl BoundBatch {
238
+ pub fn new ( batch_type : BatchType ) -> Self {
239
+ Self {
240
+ batch_type,
241
+ ..Default :: default ( )
242
+ }
243
+ }
244
+
238
245
pub ( crate ) fn from_batch (
239
246
batch : & Batch ,
240
247
values : impl BatchValues ,
241
248
) -> Result < Self , ExecutionError > {
242
249
let mut bound_batch = BoundBatch {
243
250
config : batch. config . clone ( ) ,
244
251
batch_type : batch. batch_type ,
245
- prepared : HashMap :: new ( ) ,
246
- buffer : vec ! [ ] ,
247
- first_prepared : None ,
248
252
statements_len : batch. statements . len ( ) . try_into ( ) . map_err ( |_| {
249
253
ExecutionError :: BadQuery ( BadQuery :: TooManyQueriesInBatchStatement (
250
254
batch. statements . len ( ) ,
251
255
) )
252
256
} ) ?,
257
+ ..Default :: default ( )
253
258
} ;
254
259
255
260
let mut values = values. batch_values_iter ( ) ;
@@ -329,17 +334,17 @@ impl BoundBatch {
329
334
}
330
335
331
336
/// Borrows the execution profile handle associated with this batch.
332
- pub ( crate ) fn get_execution_profile_handle ( & self ) -> Option < & ExecutionProfileHandle > {
337
+ pub fn get_execution_profile_handle ( & self ) -> Option < & ExecutionProfileHandle > {
333
338
self . config . execution_profile_handle . as_ref ( )
334
339
}
335
340
336
341
/// Gets the default timestamp for this batch in microseconds.
337
- pub ( crate ) fn get_timestamp ( & self ) -> Option < i64 > {
342
+ pub fn get_timestamp ( & self ) -> Option < i64 > {
338
343
self . config . timestamp
339
344
}
340
345
341
346
/// Gets type of batch.
342
- pub ( crate ) fn get_type ( & self ) -> BatchType {
347
+ pub fn get_type ( & self ) -> BatchType {
343
348
self . batch_type
344
349
}
345
350
@@ -398,6 +403,19 @@ fn serialize_statement<T>(
398
403
Ok ( Some ( res) )
399
404
}
400
405
406
+ impl Default for BoundBatch {
407
+ fn default ( ) -> Self {
408
+ Self {
409
+ config : StatementConfig :: default ( ) ,
410
+ batch_type : BatchType :: Logged ,
411
+ buffer : Vec :: new ( ) ,
412
+ prepared : HashMap :: new ( ) ,
413
+ first_prepared : None ,
414
+ statements_len : 0 ,
415
+ }
416
+ }
417
+ }
418
+
401
419
fn counts_mismatch_err ( n_value_lists : usize , n_statements : u16 ) -> BatchSerializationError {
402
420
BatchSerializationError :: ValuesAndStatementsLengthMismatch {
403
421
n_value_lists,
0 commit comments