pub struct AnyStateAction { /* private fields */ }Expand description
Type-erased state action that can be applied to a JSON document.
Created via AnyStateAction::new / new_at /
new_for_call from a concrete StateSpec type and
reducer action.
Implementations§
Source§impl AnyStateAction
impl AnyStateAction
Sourcepub fn to_serialized_state_action(&self) -> SerializedStateAction
pub fn to_serialized_state_action(&self) -> SerializedStateAction
Convert this action into a serialized form for persistence.
Source§impl AnyStateAction
impl AnyStateAction
Sourcepub fn new<S: StateSpec>(action: S::Action) -> Self
pub fn new<S: StateSpec>(action: S::Action) -> Self
Create a type-erased action for non-ToolCall-scoped state S.
The scope is read from S::SCOPE (Thread or Run). For ToolCall-scoped
state, use new_for_call instead.
§Panics
Panics if S::PATH is empty or S::SCOPE is ToolCall.
Sourcepub fn new_at<S: StateSpec>(path: impl Into<String>, action: S::Action) -> Self
pub fn new_at<S: StateSpec>(path: impl Into<String>, action: S::Action) -> Self
Create a type-erased action targeting an explicit thread/run base path.
This is the preferred way to use typed reducers with dynamically chosen state paths while still avoiding raw patch actions.
§Panics
Panics if S::SCOPE is ToolCall.
Sourcepub fn new_for_call<S: StateSpec>(
action: S::Action,
call_id: impl Into<String>,
) -> Self
pub fn new_for_call<S: StateSpec>( action: S::Action, call_id: impl Into<String>, ) -> Self
Create a type-erased action targeting a specific tool call scope.
The call_id determines which __tool_call_scope.<id> namespace the
action is routed to.
§Panics
Panics if S::PATH is empty or S::SCOPE is not ToolCall.
Sourcepub fn new_for_call_at<S: StateSpec>(
path: impl Into<String>,
action: S::Action,
call_id: impl Into<String>,
) -> Self
pub fn new_for_call_at<S: StateSpec>( path: impl Into<String>, action: S::Action, call_id: impl Into<String>, ) -> Self
Create a type-erased tool-call-scoped action targeting an explicit path.
§Panics
Panics if S::SCOPE is not ToolCall.
Sourcepub fn state_type_id(&self) -> TypeId
pub fn state_type_id(&self) -> TypeId
The TypeId of the state type this action targets.
Sourcepub fn state_type_name(&self) -> &str
pub fn state_type_name(&self) -> &str
Human-readable name of the state type (for diagnostics).
Sourcepub fn scope(&self) -> StateScope
pub fn scope(&self) -> StateScope
Scope of the targeted state.
Sourcepub fn call_id_override(&self) -> Option<&str>
pub fn call_id_override(&self) -> Option<&str>
Optional tool-call scope override captured for recovery/internal flows.
Sourcepub fn serialized_payload(&self) -> &Value
pub fn serialized_payload(&self) -> &Value
The serialized action payload captured before the action is moved into the reduce closure.