formualizer_eval/engine/
effects.rs1use crate::engine::vertex::VertexId;
13use crate::reference::CellRef;
14use formualizer_common::LiteralValue;
15use std::sync::{Arc, Mutex};
16
17#[doc(hidden)]
21#[derive(Debug)]
22pub struct RecordedResult {
23 vertex: VertexId,
24 value: LiteralValue,
25 pass: Arc<()>,
26 reads: Mutex<Option<Vec<crate::engine::authority::host::ObservedRect>>>,
27}
28
29impl RecordedResult {
30 pub(crate) fn new(
31 vertex: VertexId,
32 value: LiteralValue,
33 pass: Arc<()>,
34 reads: Vec<crate::engine::authority::host::ObservedRect>,
35 ) -> Self {
36 Self {
37 vertex,
38 value,
39 pass,
40 reads: Mutex::new(Some(reads)),
41 }
42 }
43
44 pub(crate) fn vertex(&self) -> VertexId {
45 self.vertex
46 }
47 pub(crate) fn value(&self) -> &LiteralValue {
48 &self.value
49 }
50 pub(crate) fn belongs_to_pass(&self, pass: &Arc<()>) -> bool {
51 Arc::ptr_eq(&self.pass, pass)
52 }
53 pub(crate) fn take_reads(&self) -> Option<Vec<crate::engine::authority::host::ObservedRect>> {
54 self.reads.lock().unwrap().take()
55 }
56}
57
58#[derive(Debug, Clone)]
60pub enum Effect {
61 WriteCell {
63 vertex_id: VertexId,
64 value: LiteralValue,
65 },
66 #[doc(hidden)]
69 WriteRecordedCell { result: Arc<RecordedResult> },
70 SpillCommit {
72 anchor_vertex: VertexId,
73 anchor_cell: CellRef,
74 target_cells: Vec<CellRef>,
75 values: Vec<Vec<LiteralValue>>,
76 },
77 SpillClear { anchor_vertex: VertexId },
79}
80
81pub type EffectBatch = Vec<(VertexId, Vec<Effect>)>;