pub trait Channel: Send {
// Required methods
fn recv<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Option<ChannelMessage>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn send<'life0, 'async_trait>(
&'life0 self,
output: ChannelOutput,
) -> Pin<Box<dyn Future<Output = Result<(), ChannelError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
}Expand description
Re-export channel types from bob_core for convenience.
Abstract channel for multi-endpoint agent interaction.
Each channel implementation handles the transport-specific details of receiving user input and delivering agent output. The agent loop is decoupled from any specific transport.
§Implementing a Channel
ⓘ
use bob_core::channel::{Channel, ChannelMessage, ChannelOutput, ChannelError};
struct MyTelegramChannel { /* ... */ }
#[async_trait::async_trait]
impl Channel for MyTelegramChannel {
async fn recv(&mut self) -> Option<ChannelMessage> {
// Poll Telegram API for new messages...
}
async fn send(&self, output: ChannelOutput) -> Result<(), ChannelError> {
// Send via Telegram Bot API...
Ok(())
}
}Required Methods§
Sourcefn recv<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Option<ChannelMessage>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn recv<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Option<ChannelMessage>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Receive the next user input message.
Returns None when the channel is closed (e.g. user disconnected,
stdin EOF, or graceful shutdown).
Sourcefn send<'life0, 'async_trait>(
&'life0 self,
output: ChannelOutput,
) -> Pin<Box<dyn Future<Output = Result<(), ChannelError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn send<'life0, 'async_trait>(
&'life0 self,
output: ChannelOutput,
) -> Pin<Box<dyn Future<Output = Result<(), ChannelError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Send an agent response back to the user.