qubit_dcl/double_checked/
executor_builder.rs1use std::marker::PhantomData;
16
17use super::{ExecutionLogger, executor_lock_builder::ExecutorLockBuilder};
18use crate::lock::Lock;
19
20#[derive(Debug, Default, Clone)]
28pub struct ExecutorBuilder {
29 logger: ExecutionLogger,
31
32 catch_panics: bool,
34}
35
36impl ExecutorBuilder {
37 #[inline]
39 pub fn log_unmet_condition(mut self, level: log::Level, message: impl Into<String>) -> Self {
40 self.logger.set_unmet_condition(Some(level), message);
41 self
42 }
43
44 #[inline]
46 pub fn disable_unmet_condition_logging(mut self) -> Self {
47 self.logger.disable_unmet_condition();
48 self
49 }
50
51 #[inline]
53 pub fn log_prepare_failure(
54 mut self,
55 level: log::Level,
56 message_prefix: impl Into<String>,
57 ) -> Self {
58 self.logger.set_prepare_failure(Some(level), message_prefix);
59 self
60 }
61
62 #[inline]
64 pub fn disable_prepare_failure_logging(mut self) -> Self {
65 self.logger.disable_prepare_failure();
66 self
67 }
68
69 #[inline]
71 pub fn log_prepare_commit_failure(
72 mut self,
73 level: log::Level,
74 message_prefix: impl Into<String>,
75 ) -> Self {
76 self.logger
77 .set_prepare_commit_failure(Some(level), message_prefix);
78 self
79 }
80
81 #[inline]
83 pub fn disable_prepare_commit_failure_logging(mut self) -> Self {
84 self.logger.disable_prepare_commit_failure();
85 self
86 }
87
88 #[inline]
90 pub fn log_prepare_rollback_failure(
91 mut self,
92 level: log::Level,
93 message_prefix: impl Into<String>,
94 ) -> Self {
95 self.logger
96 .set_prepare_rollback_failure(Some(level), message_prefix);
97 self
98 }
99
100 #[inline]
102 pub fn disable_prepare_rollback_failure_logging(mut self) -> Self {
103 self.logger.disable_prepare_rollback_failure();
104 self
105 }
106
107 #[inline]
118 pub fn on<L, T>(self, lock: L) -> ExecutorLockBuilder<L, T>
119 where
120 L: Lock<T>,
121 {
122 ExecutorLockBuilder {
123 lock,
124 logger: self.logger,
125 catch_panics: self.catch_panics,
126 _phantom: PhantomData,
127 }
128 }
129
130 #[inline]
132 pub fn catch_panics(mut self) -> Self {
133 self.catch_panics = true;
134 self
135 }
136
137 #[inline]
140 pub fn set_catch_panics(mut self, catch_panics: bool) -> Self {
141 self.catch_panics = catch_panics;
142 self
143 }
144
145 #[inline]
147 pub fn disable_catch_panics(mut self) -> Self {
148 self.catch_panics = false;
149 self
150 }
151}