@@ -249,7 +249,7 @@ impl<'a: 'b, 'b> From<&'a BatchStatement>
249249}
250250
251251/// A batch with all of its statements bound to values
252- pub ( crate ) struct BoundBatch {
252+ pub struct BoundBatch {
253253 pub ( crate ) config : StatementConfig ,
254254 batch_type : BatchType ,
255255 pub ( crate ) buffer : Vec < u8 > ,
@@ -259,6 +259,13 @@ pub(crate) struct BoundBatch {
259259}
260260
261261impl BoundBatch {
262+ pub fn new ( batch_type : BatchType ) -> Self {
263+ Self {
264+ batch_type,
265+ ..Default :: default ( )
266+ }
267+ }
268+
262269 #[ allow( clippy:: result_large_err) ]
263270 pub ( crate ) fn from_batch (
264271 batch : & Batch ,
@@ -267,14 +274,12 @@ impl BoundBatch {
267274 let mut bound_batch = BoundBatch {
268275 config : batch. config . clone ( ) ,
269276 batch_type : batch. batch_type ,
270- prepared : HashMap :: new ( ) ,
271- buffer : vec ! [ ] ,
272- first_prepared : None ,
273277 statements_len : batch. statements . len ( ) . try_into ( ) . map_err ( |_| {
274278 ExecutionError :: BadQuery ( BadQuery :: TooManyQueriesInBatchStatement (
275279 batch. statements . len ( ) ,
276280 ) )
277281 } ) ?,
282+ ..Default :: default ( )
278283 } ;
279284
280285 let mut values = values. batch_values_iter ( ) ;
@@ -356,17 +361,17 @@ impl BoundBatch {
356361 }
357362
358363 /// 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 > {
360365 self . config . execution_profile_handle . as_ref ( )
361366 }
362367
363368 /// 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 > {
365370 self . config . timestamp
366371 }
367372
368373 /// Gets type of batch.
369- pub ( crate ) fn get_type ( & self ) -> BatchType {
374+ pub fn get_type ( & self ) -> BatchType {
370375 self . batch_type
371376 }
372377
@@ -425,6 +430,19 @@ fn serialize_statement<T>(
425430 Ok ( Some ( res) )
426431}
427432
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+
428446fn counts_mismatch_err ( n_value_lists : usize , n_statements : u16 ) -> BatchSerializationError {
429447 BatchSerializationError :: ValuesAndStatementsLengthMismatch {
430448 n_value_lists,
0 commit comments