AnyStateAction

Struct AnyStateAction 

Source
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

Source

pub fn to_serialized_state_action(&self) -> SerializedStateAction

Convert this action into a serialized form for persistence.

Source§

impl AnyStateAction

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn state_type_id(&self) -> TypeId

The TypeId of the state type this action targets.

Source

pub fn state_type_name(&self) -> &str

Human-readable name of the state type (for diagnostics).

Source

pub fn scope(&self) -> StateScope

Scope of the targeted state.

Source

pub fn base_path(&self) -> &str

Canonical base JSON path for the targeted state.

Source

pub fn call_id_override(&self) -> Option<&str>

Optional tool-call scope override captured for recovery/internal flows.

Source

pub fn serialized_payload(&self) -> &Value

The serialized action payload captured before the action is moved into the reduce closure.

Trait Implementations§

Source§

impl Debug for AnyStateAction

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<AnyStateAction> for ActionSet<AfterInferenceAction>

Source§

fn from(sa: AnyStateAction) -> Self

Converts to this type from the input type.
Source§

impl From<AnyStateAction> for ActionSet<AfterToolExecuteAction>

Source§

fn from(sa: AnyStateAction) -> Self

Converts to this type from the input type.
Source§

impl From<AnyStateAction> for ActionSet<BeforeInferenceAction>

Source§

fn from(sa: AnyStateAction) -> Self

Converts to this type from the input type.
Source§

impl From<AnyStateAction> for ActionSet<BeforeToolExecuteAction>

Source§

fn from(sa: AnyStateAction) -> Self

Converts to this type from the input type.
Source§

impl From<AnyStateAction> for ActionSet<LifecycleAction>

Source§

fn from(sa: AnyStateAction) -> Self

Converts to this type from the input type.
Source§

impl From<AnyStateAction> for AfterInferenceAction

Source§

fn from(sa: AnyStateAction) -> Self

Converts to this type from the input type.
Source§

impl From<AnyStateAction> for AfterToolExecuteAction

Source§

fn from(sa: AnyStateAction) -> Self

Converts to this type from the input type.
Source§

impl From<AnyStateAction> for BeforeInferenceAction

Source§

fn from(sa: AnyStateAction) -> Self

Converts to this type from the input type.
Source§

impl From<AnyStateAction> for BeforeToolExecuteAction

Source§

fn from(sa: AnyStateAction) -> Self

Converts to this type from the input type.
Source§

impl From<AnyStateAction> for LifecycleAction

Source§

fn from(sa: AnyStateAction) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more