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
})
}
}