@@ -226,6 +226,7 @@ pub(crate) mod defaults {
226226/// # Ok(())
227227/// # }
228228/// ```
229+ #[ derive( Clone , Debug ) ]
229230pub struct ExecutionProfileBuilder {
230231 request_timeout : Option < Option < Duration > > ,
231232 consistency : Option < Consistency > ,
@@ -378,6 +379,12 @@ impl ExecutionProfileBuilder {
378379 }
379380}
380381
382+ impl Default for ExecutionProfileBuilder {
383+ fn default ( ) -> Self {
384+ ExecutionProfile :: builder ( )
385+ }
386+ }
387+
381388/// A profile that groups configurable options regarding query execution.
382389///
383390/// Execution profile is immutable as such, but the driver implements double indirection of form:
@@ -399,6 +406,20 @@ pub(crate) struct ExecutionProfileInner {
399406 pub ( crate ) speculative_execution_policy : Option < Arc < dyn SpeculativeExecutionPolicy > > ,
400407}
401408
409+ impl ExecutionProfileInner {
410+ /// Creates a builder having all options set to the same as set in this ExecutionProfileInner.
411+ pub ( crate ) fn to_builder ( & self ) -> ExecutionProfileBuilder {
412+ ExecutionProfileBuilder {
413+ request_timeout : Some ( self . request_timeout ) ,
414+ consistency : Some ( self . consistency ) ,
415+ serial_consistency : Some ( self . serial_consistency ) ,
416+ load_balancing_policy : Some ( self . load_balancing_policy . clone ( ) ) ,
417+ retry_policy : Some ( self . retry_policy . clone ( ) ) ,
418+ speculative_execution_policy : Some ( self . speculative_execution_policy . clone ( ) ) ,
419+ }
420+ }
421+ }
422+
402423impl ExecutionProfile {
403424 pub ( crate ) fn new_from_inner ( inner : ExecutionProfileInner ) -> Self {
404425 Self ( Arc :: new ( inner) )
@@ -418,14 +439,7 @@ impl ExecutionProfile {
418439
419440 /// Creates a builder having all options set to the same as set in this ExecutionProfile.
420441 pub fn to_builder ( & self ) -> ExecutionProfileBuilder {
421- ExecutionProfileBuilder {
422- request_timeout : Some ( self . 0 . request_timeout ) ,
423- consistency : Some ( self . 0 . consistency ) ,
424- serial_consistency : Some ( self . 0 . serial_consistency ) ,
425- load_balancing_policy : Some ( self . 0 . load_balancing_policy . clone ( ) ) ,
426- retry_policy : Some ( self . 0 . retry_policy . clone ( ) ) ,
427- speculative_execution_policy : Some ( self . 0 . speculative_execution_policy . clone ( ) ) ,
428- }
442+ self . 0 . to_builder ( )
429443 }
430444
431445 /// Returns a new handle to this ExecutionProfile.
@@ -461,6 +475,11 @@ impl ExecutionProfileHandle {
461475 self . 0 . 0 . load_full ( )
462476 }
463477
478+ /// Creates a builder having all options set to the same as set in the ExecutionProfile pointed by this handle.
479+ pub fn pointee_to_builder ( & self ) -> ExecutionProfileBuilder {
480+ self . 0 . 0 . load ( ) . to_builder ( )
481+ }
482+
464483 /// Makes the handle point to a new execution profile.
465484 /// All entities (queries/Session) holding this handle will reflect the change.
466485 pub fn map_to_another_profile ( & mut self , profile : ExecutionProfile ) {
0 commit comments