Skip to main content

jellyflow_runtime/runtime/xyflow/
store.rs

1//! Store helpers for XyFlow-style change arrays.
2
3use crate::runtime::store::{DispatchError, DispatchOutcome, NodeGraphStore};
4use crate::runtime::xyflow::changes::{ChangesToTransactionError, NodeGraphChanges};
5
6#[derive(Debug, thiserror::Error)]
7pub enum DispatchChangesError {
8    #[error(transparent)]
9    Changes(#[from] ChangesToTransactionError),
10    #[error(transparent)]
11    Dispatch(#[from] DispatchError),
12}
13
14impl NodeGraphStore {
15    /// Applies XyFlow-style changes by converting them to a reversible transaction.
16    pub fn dispatch_changes(
17        &mut self,
18        changes: &NodeGraphChanges,
19    ) -> Result<DispatchOutcome, DispatchChangesError> {
20        let tx = changes.to_transaction(self.graph())?;
21        Ok(self.dispatch_transaction(&tx)?)
22    }
23}