pub struct GraphState { /* private fields */ }Expand description
The shared state that flows through the graph execution
Implementations§
Source§impl GraphState
impl GraphState
Sourcepub fn with_data(data: HashMap<String, StateValue>) -> Self
pub fn with_data(data: HashMap<String, StateValue>) -> Self
Create a new graph state with initial data
Sourcepub fn set(&self, key: impl Into<String>, value: impl Into<StateValue>) -> &Self
pub fn set(&self, key: impl Into<String>, value: impl Into<StateValue>) -> &Self
Set a value in the state
Sourcepub fn set_with_context(
&self,
node_id: &str,
key: impl Into<String>,
value: impl Into<StateValue>,
) -> &Self
pub fn set_with_context( &self, node_id: &str, key: impl Into<String>, value: impl Into<StateValue>, ) -> &Self
Set a value in the state with node context
Sourcepub fn get(&self, key: &str) -> RGraphResult<StateValue>
pub fn get(&self, key: &str) -> RGraphResult<StateValue>
Get a value from the state
Sourcepub fn get_by_path(&self, path: &StatePath) -> RGraphResult<StateValue>
pub fn get_by_path(&self, path: &StatePath) -> RGraphResult<StateValue>
Get a value by path (supports nested access)
Sourcepub fn get_typed<T>(&self, key: &str) -> RGraphResult<T>
pub fn get_typed<T>(&self, key: &str) -> RGraphResult<T>
Get a typed value from the state
Sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
Check if a key exists in the state
Sourcepub fn remove(&self, key: &str) -> Option<StateValue>
pub fn remove(&self, key: &str) -> Option<StateValue>
Remove a value from the state
Sourcepub fn merge(&self, other: &GraphState)
pub fn merge(&self, other: &GraphState)
Merge another state into this one
Sourcepub fn snapshot(&self) -> HashMap<String, StateValue>
pub fn snapshot(&self) -> HashMap<String, StateValue>
Create a snapshot of the current state
Sourcepub fn set_metadata(&self, key: impl Into<String>, value: impl Into<StateValue>)
pub fn set_metadata(&self, key: impl Into<String>, value: impl Into<StateValue>)
Set metadata
Sourcepub fn get_metadata(&self, key: &str) -> Option<StateValue>
pub fn get_metadata(&self, key: &str) -> Option<StateValue>
Get metadata
Sourcepub fn execution_history(&self) -> Vec<StateHistoryEntry>
pub fn execution_history(&self) -> Vec<StateHistoryEntry>
Get execution history
Sourcepub fn with_input(
self,
key: impl Into<String>,
value: impl Into<StateValue>,
) -> Self
pub fn with_input( self, key: impl Into<String>, value: impl Into<StateValue>, ) -> Self
Convenience method to add input data
Sourcepub fn get_output<T>(&self, key: &str) -> RGraphResult<T>
pub fn get_output<T>(&self, key: &str) -> RGraphResult<T>
Get output data as a specific type
Trait Implementations§
Source§impl Clone for GraphState
impl Clone for GraphState
Source§fn clone(&self) -> GraphState
fn clone(&self) -> GraphState
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for GraphState
impl Debug for GraphState
Source§impl Default for GraphState
impl Default for GraphState
Source§impl<'de> Deserialize<'de> for GraphState
impl<'de> Deserialize<'de> for GraphState
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for GraphState
impl !RefUnwindSafe for GraphState
impl Send for GraphState
impl Sync for GraphState
impl Unpin for GraphState
impl !UnwindSafe for GraphState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more