Skip to main content

AgentOutput

Trait AgentOutput 

Source
pub trait AgentOutput {
    // Required methods
    fn output_raw(
        &self,
        ctx: AgentContext,
        port: String,
        value: AgentValue,
    ) -> Pin<Box<dyn Future<Output = Result<(), AgentError>> + Send + '_>>;
    fn try_output_raw(
        &self,
        ctx: AgentContext,
        port: String,
        value: AgentValue,
    ) -> Result<(), AgentError>;
    fn emit_config_updated_raw(&self, key: String, value: AgentValue);
    fn emit_agent_spec_updated_raw(&self);
    fn emit_error_raw(&self, message: String);

    // Provided methods
    fn output<S: Into<String>>(
        &self,
        ctx: AgentContext,
        port: S,
        value: AgentValue,
    ) -> Pin<Box<dyn Future<Output = Result<(), AgentError>> + Send + '_>> { ... }
    fn try_output<S: Into<String>>(
        &self,
        ctx: AgentContext,
        port: S,
        value: AgentValue,
    ) -> Result<(), AgentError> { ... }
    fn emit_config_updated<S: Into<String>>(&self, key: S, value: AgentValue) { ... }
    fn emit_agent_spec_updated(&self) { ... }
    fn emit_error<S: Into<String>>(&self, message: S) { ... }
}
Expand description

Trait for sending output values and emitting events from agents.

This trait is automatically implemented for all types that implement Agent. It provides methods for sending values to output ports and notifying the orchestrator about configuration changes and errors.

Required Methods§

Source

fn output_raw( &self, ctx: AgentContext, port: String, value: AgentValue, ) -> Pin<Box<dyn Future<Output = Result<(), AgentError>> + Send + '_>>

Sends a value to an output port asynchronously (raw version with String port).

This is the low-level method; prefer using output() which accepts any type that can be converted to String.

Source

fn try_output_raw( &self, ctx: AgentContext, port: String, value: AgentValue, ) -> Result<(), AgentError>

Tries to send a value to an output port without blocking (raw version).

Returns immediately, even if the channel is full.

Source

fn emit_config_updated_raw(&self, key: String, value: AgentValue)

Emits a configuration update event (raw version with String key).

Source

fn emit_agent_spec_updated_raw(&self)

Emits an agent spec update event (raw version).

Source

fn emit_error_raw(&self, message: String)

Emits an error event (raw version with String message).

Provided Methods§

Source

fn output<S: Into<String>>( &self, ctx: AgentContext, port: S, value: AgentValue, ) -> Pin<Box<dyn Future<Output = Result<(), AgentError>> + Send + '_>>

Sends a value to an output port asynchronously.

This method waits until the value is accepted by the channel. Use try_output if you want non-blocking behavior.

Source

fn try_output<S: Into<String>>( &self, ctx: AgentContext, port: S, value: AgentValue, ) -> Result<(), AgentError>

Tries to send a value to an output port without blocking.

Source

fn emit_config_updated<S: Into<String>>(&self, key: S, value: AgentValue)

Emits a configuration update event.

Notifies the orchestrator that a configuration value has changed, typically used when an agent updates its own configuration.

Source

fn emit_agent_spec_updated(&self)

Emits an agent spec update event.

Notifies the orchestrator that the agent’s specification has changed (e.g., ports were added or removed dynamically).

Source

fn emit_error<S: Into<String>>(&self, message: S)

Emits an error event.

Notifies the orchestrator that an error occurred in this agent.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T: Agent> AgentOutput for T