qubit_dcl/double_checked/
executor_builder.rs1use std::marker::PhantomData;
14
15use super::{ExecutionLogger, executor_lock_builder::ExecutorLockBuilder};
16use crate::lock::Lock;
17
18#[derive(Debug, Default, Clone)]
23pub struct ExecutorBuilder {
24 logger: ExecutionLogger,
26
27 catch_panics: bool,
29}
30
31impl ExecutorBuilder {
32 #[inline]
34 pub fn log_unmet_condition(mut self, level: log::Level, message: impl Into<String>) -> Self {
35 self.logger.set_unmet_condition(Some(level), message);
36 self
37 }
38
39 #[inline]
41 pub fn disable_unmet_condition_logging(mut self) -> Self {
42 self.logger.disable_unmet_condition();
43 self
44 }
45
46 #[inline]
48 pub fn log_prepare_failure(
49 mut self,
50 level: log::Level,
51 message_prefix: impl Into<String>,
52 ) -> Self {
53 self.logger.set_prepare_failure(Some(level), message_prefix);
54 self
55 }
56
57 #[inline]
59 pub fn disable_prepare_failure_logging(mut self) -> Self {
60 self.logger.disable_prepare_failure();
61 self
62 }
63
64 #[inline]
66 pub fn log_prepare_commit_failure(
67 mut self,
68 level: log::Level,
69 message_prefix: impl Into<String>,
70 ) -> Self {
71 self.logger
72 .set_prepare_commit_failure(Some(level), message_prefix);
73 self
74 }
75
76 #[inline]
78 pub fn disable_prepare_commit_failure_logging(mut self) -> Self {
79 self.logger.disable_prepare_commit_failure();
80 self
81 }
82
83 #[inline]
85 pub fn log_prepare_rollback_failure(
86 mut self,
87 level: log::Level,
88 message_prefix: impl Into<String>,
89 ) -> Self {
90 self.logger
91 .set_prepare_rollback_failure(Some(level), message_prefix);
92 self
93 }
94
95 #[inline]
97 pub fn disable_prepare_rollback_failure_logging(mut self) -> Self {
98 self.logger.disable_prepare_rollback_failure();
99 self
100 }
101
102 #[inline]
113 pub fn on<L, T>(self, lock: L) -> ExecutorLockBuilder<L, T>
114 where
115 L: Lock<T>,
116 {
117 ExecutorLockBuilder {
118 lock,
119 logger: self.logger,
120 catch_panics: self.catch_panics,
121 _phantom: PhantomData,
122 }
123 }
124
125 #[inline]
127 pub fn catch_panics(mut self) -> Self {
128 self.catch_panics = true;
129 self
130 }
131
132 #[inline]
135 pub fn set_catch_panics(mut self, catch_panics: bool) -> Self {
136 self.catch_panics = catch_panics;
137 self
138 }
139
140 #[inline]
142 pub fn disable_catch_panics(mut self) -> Self {
143 self.catch_panics = false;
144 self
145 }
146}