pub trait Channel: Send + Sync {
// Required methods
fn id(&self) -> &ChannelId;
fn caps(&self) -> &ChannelCaps;
fn run<'life0, 'async_trait>(
&'life0 self,
sink: Arc<dyn InboundSink>,
shutdown: CancellationToken,
) -> Pin<Box<dyn Future<Output = Result<(), ChannelError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn send<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
to: &'life1 ReplyTarget,
message: &'life2 RenderedMessage,
) -> Pin<Box<dyn Future<Output = Result<SentRef, ChannelError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
// Provided methods
fn edit<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_sent: &'life1 SentRef,
_message: &'life2 RenderedMessage,
) -> Pin<Box<dyn Future<Output = Result<(), ChannelError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn typing<'life0, 'life1, 'async_trait>(
&'life0 self,
_to: &'life1 ReplyTarget,
) -> Pin<Box<dyn Future<Output = Result<(), ChannelError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn prompt<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_to: &'life1 ReplyTarget,
_prompt: &'life2 Prompt,
) -> Pin<Box<dyn Future<Output = Result<SentRef, ChannelError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn close_prompt<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_sent: &'life1 SentRef,
_message: &'life2 RenderedMessage,
_keep_buttons: bool,
) -> Pin<Box<dyn Future<Output = Result<(), ChannelError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn set_commands<'life0, 'life1, 'async_trait>(
&'life0 self,
_commands: &'life1 [CommandInfo],
) -> Pin<Box<dyn Future<Output = Result<(), ChannelError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn webhook(&self) -> Option<Arc<dyn WebhookHandler>> { ... }
}Expand description
A chat platform adapter (design §3.2).
A channel receives events (through Channel::run or a WebhookHandler) and sends replies.
It knows nothing about agents or knowledge.
Required Methods§
Sourcefn caps(&self) -> &ChannelCaps
fn caps(&self) -> &ChannelCaps
What the platform supports.
Sourcefn run<'life0, 'async_trait>(
&'life0 self,
sink: Arc<dyn InboundSink>,
shutdown: CancellationToken,
) -> Pin<Box<dyn Future<Output = Result<(), ChannelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn run<'life0, 'async_trait>(
&'life0 self,
sink: Arc<dyn InboundSink>,
shutdown: CancellationToken,
) -> Pin<Box<dyn Future<Output = Result<(), ChannelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Receives events until shutdown is cancelled, delivering them to sink.
Polling and socket platforms loop here and reconnect on their own. Webhook platforms may
only do start-up work (such as registering the webhook) and then wait for shutdown.
Returning an error stops this channel only.
Sourcefn send<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
to: &'life1 ReplyTarget,
message: &'life2 RenderedMessage,
) -> Pin<Box<dyn Future<Output = Result<SentRef, ChannelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn send<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
to: &'life1 ReplyTarget,
message: &'life2 RenderedMessage,
) -> Pin<Box<dyn Future<Output = Result<SentRef, ChannelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Sends one message.
Provided Methods§
Sourcefn edit<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_sent: &'life1 SentRef,
_message: &'life2 RenderedMessage,
) -> Pin<Box<dyn Future<Output = Result<(), ChannelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn edit<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_sent: &'life1 SentRef,
_message: &'life2 RenderedMessage,
) -> Pin<Box<dyn Future<Output = Result<(), ChannelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Replaces the text of a sent message. Only called when ChannelCaps::edit is true.
Sourcefn typing<'life0, 'life1, 'async_trait>(
&'life0 self,
_to: &'life1 ReplyTarget,
) -> Pin<Box<dyn Future<Output = Result<(), ChannelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn typing<'life0, 'life1, 'async_trait>(
&'life0 self,
_to: &'life1 ReplyTarget,
) -> Pin<Box<dyn Future<Output = Result<(), ChannelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Shows a typing indicator once. The runtime repeats it while an agent works.
Sourcefn prompt<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_to: &'life1 ReplyTarget,
_prompt: &'life2 Prompt,
) -> Pin<Box<dyn Future<Output = Result<SentRef, ChannelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn prompt<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_to: &'life1 ReplyTarget,
_prompt: &'life2 Prompt,
) -> Pin<Box<dyn Future<Output = Result<SentRef, ChannelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Shows a prompt (a message with buttons) in a conversation. Answers come back through
InboundSink::answer. Platforms without buttons return ChannelError::Unsupported.
Sourcefn close_prompt<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_sent: &'life1 SentRef,
_message: &'life2 RenderedMessage,
_keep_buttons: bool,
) -> Pin<Box<dyn Future<Output = Result<(), ChannelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn close_prompt<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_sent: &'life1 SentRef,
_message: &'life2 RenderedMessage,
_keep_buttons: bool,
) -> Pin<Box<dyn Future<Output = Result<(), ChannelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Replaces a prompt’s text and removes its buttons (answered, cancelled or expired). With
keep_buttons, only the text changes and the prompt can be answered again.
Sourcefn set_commands<'life0, 'life1, 'async_trait>(
&'life0 self,
_commands: &'life1 [CommandInfo],
) -> Pin<Box<dyn Future<Output = Result<(), ChannelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn set_commands<'life0, 'life1, 'async_trait>(
&'life0 self,
_commands: &'life1 [CommandInfo],
) -> Pin<Box<dyn Future<Output = Result<(), ChannelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Lists the bot’s commands in the platform’s command menu. Called once, before
Channel::run, and only when the bot has commands of its own. Commands always arrive as
text messages starting with /name: platforms whose menu sends something else (Discord’s
slash commands) turn it into such a message. Platforms without a menu ignore this.
Sourcefn webhook(&self) -> Option<Arc<dyn WebhookHandler>>
fn webhook(&self) -> Option<Arc<dyn WebhookHandler>>
The webhook endpoint, for platforms that push events over HTTP.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".