pub struct StateReconstructor { /* private fields */ }Expand description
Reconstructs agent state from AG-UI events.
This struct tracks the current agent state and message history, updating them as events are received. It handles both snapshot and delta events for efficient state synchronization.
Implementations§
Source§impl StateReconstructor
impl StateReconstructor
Sourcepub fn with_state(initial: JsonValue) -> Self
pub fn with_state(initial: JsonValue) -> Self
Creates a new state reconstructor with initial state.
Sourcepub fn into_state(self) -> JsonValue
pub fn into_state(self) -> JsonValue
Returns the current state, consuming the reconstructor.
Sourcepub fn is_run_active(&self) -> bool
pub fn is_run_active(&self) -> bool
Returns whether a run is currently active.
Sourcepub fn apply_event(&mut self, event: &Event<JsonValue>) -> Result<()>
pub fn apply_event(&mut self, event: &Event<JsonValue>) -> Result<()>
Applies an event to update the state.
This method processes the event and updates the internal state accordingly. State snapshots replace the entire state, while deltas are applied as JSON Patches.
Sourcepub fn apply_delta(&mut self, delta: &[JsonValue]) -> Result<()>
pub fn apply_delta(&mut self, delta: &[JsonValue]) -> Result<()>
Applies a JSON Patch delta to the current state.
Sourcepub fn apply_patch(&mut self, patch: &Patch) -> Result<()>
pub fn apply_patch(&mut self, patch: &Patch) -> Result<()>
Applies a Patch directly to the current state.
Sourcepub fn get_as<T: DeserializeOwned>(&self, path: &str) -> Option<T>
pub fn get_as<T: DeserializeOwned>(&self, path: &str) -> Option<T>
Gets a typed value from the state by JSON pointer path.
Returns None if the path doesn’t exist or the value can’t be
deserialized to the target type.
Trait Implementations§
Source§impl Clone for StateReconstructor
impl Clone for StateReconstructor
Source§fn clone(&self) -> StateReconstructor
fn clone(&self) -> StateReconstructor
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more