Skip to main content

InputSource

Trait InputSource 

Source
pub trait InputSource: Send + 'static {
    // Required method
    fn recv(
        &mut self,
    ) -> Pin<Box<dyn Future<Output = Option<ControllerInputPayload>> + Send + '_>>;
}
Expand description

Provides input from a consumer to the agent engine.

Implementations handle receiving user messages, commands, and other input from the consumer and delivering them to the engine.

§Lifecycle

The engine calls recv() in a loop. When the consumer closes (user quits, connection dropped), recv() should return None to signal shutdown.

§Example

use agent_core_runtime::agent::interface::InputSource;
use agent_core_runtime::controller::ControllerInputPayload;
use std::pin::Pin;
use std::future::Future;

struct MyCustomSource { /* ... */ }

impl InputSource for MyCustomSource {
    fn recv(&mut self) -> Pin<Box<dyn Future<Output = Option<ControllerInputPayload>> + Send + '_>> {
        Box::pin(async move {
            // Receive from your transport
            None
        })
    }
}

Required Methods§

Source

fn recv( &mut self, ) -> Pin<Box<dyn Future<Output = Option<ControllerInputPayload>> + Send + '_>>

Receive the next input from the consumer.

Returns None when the consumer is closed and no more input will arrive. The engine will shut down when this returns None.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§