1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//! Immediate in-process implementation of the engine execution contract.
use crate::engine::{
ActivityOutcome, Execution, ExecutionTransition, HostFacts, TurnExecution, TurnState,
};
use chrono::{DateTime, Utc};
/// Turn execution whose state lives in the current process.
///
/// The host performs each planned phase immediately. All semantic state
/// advancement remains delegated to [`TurnExecution`] in `everruns_core::engine`.
#[derive(Debug, Clone)]
pub struct InProcessExecution {
inner: TurnExecution,
}
impl InProcessExecution {
/// Start an in-process execution from the common engine state.
pub fn new(state: TurnState) -> Self {
Self {
inner: TurnExecution::new(state),
}
}
/// Consume this driver and return the common checkpoint value.
pub fn into_state(self) -> TurnState {
self.inner.into_state()
}
}
impl Execution for InProcessExecution {
fn state(&self) -> &TurnState {
self.inner.state()
}
fn advance(
&mut self,
outcome: ActivityOutcome,
pending_user_message_count: usize,
now: DateTime<Utc>,
facts: HostFacts,
) -> ExecutionTransition {
self.inner
.advance(outcome, pending_user_message_count, now, facts)
}
}