Skip to content

Commit 203c1c9

Browse files
committed
execution_profiles: Extended API with pointee_to_builder()
This method will be crucial for convenient execution profiles in Cpp-Rust-driver implementation.
1 parent ccb6e11 commit 203c1c9

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

scylla/src/transport/execution_profile.rs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,20 @@ pub(crate) struct ExecutionProfileInner {
406406
pub(crate) speculative_execution_policy: Option<Arc<dyn SpeculativeExecutionPolicy>>,
407407
}
408408

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+
409423
impl ExecutionProfile {
410424
pub(crate) fn new_from_inner(inner: ExecutionProfileInner) -> Self {
411425
Self(Arc::new(inner))
@@ -425,14 +439,7 @@ impl ExecutionProfile {
425439

426440
/// Creates a builder having all options set to the same as set in this ExecutionProfile.
427441
pub fn to_builder(&self) -> ExecutionProfileBuilder {
428-
ExecutionProfileBuilder {
429-
request_timeout: Some(self.0.request_timeout),
430-
consistency: Some(self.0.consistency),
431-
serial_consistency: Some(self.0.serial_consistency),
432-
load_balancing_policy: Some(self.0.load_balancing_policy.clone()),
433-
retry_policy: Some(self.0.retry_policy.clone()),
434-
speculative_execution_policy: Some(self.0.speculative_execution_policy.clone()),
435-
}
442+
self.0.to_builder()
436443
}
437444

438445
/// Returns a new handle to this ExecutionProfile.
@@ -468,6 +475,11 @@ impl ExecutionProfileHandle {
468475
self.0 .0.load_full()
469476
}
470477

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+
471483
/// Makes the handle point to a new execution profile.
472484
/// All entities (queries/Session) holding this handle will reflect the change.
473485
pub fn map_to_another_profile(&mut self, profile: ExecutionProfile) {

0 commit comments

Comments
 (0)