Skip to main content

CoreState

Trait CoreState 

Source
pub trait CoreState: State {
    // Required methods
    fn messages(&self) -> &[Message];
    fn messages_mut(&mut self) -> &mut Vec<Message>;
    fn iterations(&self) -> u32;
    fn set_iterations(&mut self, n: u32);
    fn thread_id(&self) -> &str;
    fn context(&self) -> &ExecutionContext;
    fn context_mut(&mut self) -> &mut ExecutionContext;

    // Provided method
    fn runtime_result_metadata(&self) -> HashMap<String, Value> { ... }
}
Expand description

Core fields every agent state MUST have. Generated by #[derive(CoreState)] or detected via #core fields in #[derive(State)].

Generic nodes that work on ANY agent state bound on this trait:

#[node]
async fn prepare<S: CoreState>(state: &S) -> NodeResult<S::Update> { ... }

Required Methods§

Source

fn messages(&self) -> &[Message]

Source

fn messages_mut(&mut self) -> &mut Vec<Message>

Source

fn iterations(&self) -> u32

Source

fn set_iterations(&mut self, n: u32)

Source

fn thread_id(&self) -> &str

Source

fn context(&self) -> &ExecutionContext

Source

fn context_mut(&mut self) -> &mut ExecutionContext

Provided Methods§

Source

fn runtime_result_metadata(&self) -> HashMap<String, Value>

Optional structured metadata projection surfaced on runtime results.

Most states do not need this and can use the default empty projection. Specialized runtime-owned states can override it to expose structured execution details at the ExecutionResult boundary.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§