@@ -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,21 +259,26 @@ 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 pub ( crate ) fn from_batch (
263270 batch : & Batch ,
264271 values : impl BatchValues ,
265272 ) -> Result < Self , ExecutionError > {
266273 let mut bound_batch = BoundBatch {
267274 config : batch. config . clone ( ) ,
268275 batch_type : batch. batch_type ,
269- prepared : HashMap :: new ( ) ,
270- buffer : vec ! [ ] ,
271- first_prepared : None ,
272276 statements_len : batch. statements . len ( ) . try_into ( ) . map_err ( |_| {
273277 ExecutionError :: BadQuery ( BadQuery :: TooManyQueriesInBatchStatement (
274278 batch. statements . len ( ) ,
275279 ) )
276280 } ) ?,
281+ ..Default :: default ( )
277282 } ;
278283
279284 let mut values = values. batch_values_iter ( ) ;
@@ -353,17 +358,17 @@ impl BoundBatch {
353358 }
354359
355360 /// Borrows the execution profile handle associated with this batch.
356- pub ( crate ) fn get_execution_profile_handle ( & self ) -> Option < & ExecutionProfileHandle > {
361+ pub fn get_execution_profile_handle ( & self ) -> Option < & ExecutionProfileHandle > {
357362 self . config . execution_profile_handle . as_ref ( )
358363 }
359364
360365 /// Gets the default timestamp for this batch in microseconds.
361- pub ( crate ) fn get_timestamp ( & self ) -> Option < i64 > {
366+ pub fn get_timestamp ( & self ) -> Option < i64 > {
362367 self . config . timestamp
363368 }
364369
365370 /// Gets type of batch.
366- pub ( crate ) fn get_type ( & self ) -> BatchType {
371+ pub fn get_type ( & self ) -> BatchType {
367372 self . batch_type
368373 }
369374
@@ -422,6 +427,19 @@ fn serialize_statement<T>(
422427 Ok ( Some ( res) )
423428}
424429
430+ impl Default for BoundBatch {
431+ fn default ( ) -> Self {
432+ Self {
433+ config : StatementConfig :: default ( ) ,
434+ batch_type : BatchType :: Logged ,
435+ buffer : Vec :: new ( ) ,
436+ prepared : HashMap :: new ( ) ,
437+ first_prepared : None ,
438+ statements_len : 0 ,
439+ }
440+ }
441+ }
442+
425443fn counts_mismatch_err ( n_value_lists : usize , n_statements : u16 ) -> BatchSerializationError {
426444 BatchSerializationError :: ValuesAndStatementsLengthMismatch {
427445 n_value_lists,
0 commit comments