dex_sdk/
reset_flow_options.rs1use std::time::SystemTime;
10
11use crate::{Step, StepExecutionId};
12
13#[derive(Clone, Debug)]
14pub struct ResetFlowOptions {
20 pub(crate) point: ResetPoint,
21 pub(crate) reason: Option<String>,
22 pub(crate) skip_channel_messages_reapply: bool,
23 pub(crate) skip_locking_rpc_reapply: bool,
24}
25
26#[derive(Clone, Debug)]
27pub(crate) enum ResetPoint {
28 Beginning,
29 HistoryEventId(i64),
30 HistoryEventTime(SystemTime),
31 StepType(&'static str),
32 StepExecution(StepExecutionId),
33}
34
35impl ResetFlowOptions {
36 pub fn from_beginning() -> Self {
38 Self::new(ResetPoint::Beginning)
39 }
40
41 pub fn from_history_event_id(event_id: i64) -> Self {
43 Self::new(ResetPoint::HistoryEventId(event_id))
44 }
45
46 pub fn from_history_event_time(event_time: SystemTime) -> Self {
48 Self::new(ResetPoint::HistoryEventTime(event_time))
49 }
50
51 pub fn from_step<SomeStep: Step>(step: &SomeStep) -> Self {
53 Self::new(ResetPoint::StepType(step.step_type()))
54 }
55
56 pub fn from_step_execution(step_execution: StepExecutionId) -> Self {
58 Self::new(ResetPoint::StepExecution(step_execution))
59 }
60
61 pub fn reason(mut self, reason: impl Into<String>) -> Self {
63 self.reason = Some(reason.into());
64 self
65 }
66
67 pub fn skip_channel_messages_reapply(mut self, skip: bool) -> Self {
69 self.skip_channel_messages_reapply = skip;
70 self
71 }
72
73 pub fn skip_locking_rpc_reapply(mut self, skip: bool) -> Self {
75 self.skip_locking_rpc_reapply = skip;
76 self
77 }
78
79 fn new(point: ResetPoint) -> Self {
80 Self {
81 point,
82 reason: None,
83 skip_channel_messages_reapply: false,
84 skip_locking_rpc_reapply: false,
85 }
86 }
87}