Skip to main content

ChatActionSender

Trait ChatActionSender 

Source
pub trait ChatActionSender: ChatActionSenderBounds + 'static {
    // Required methods
    fn send_action(
        &self,
        action: ChatAction,
    ) -> impl ChatActionFutureBounds<Output = Result<(), BotError>> + '_;
    fn action_expiry(&self) -> Duration;

    // Provided method
    fn clear_action(
        &self,
    ) -> impl ChatActionFutureBounds<Output = Result<(), BotError>> + '_ { ... }
}
Expand description

Trait for sending chat actions to a channel

Platform implementations define how to send actions and their expiration times. Use AnyChatActionSender where a sender must be stored behind type erasure.

Required Methods§

Source

fn send_action( &self, action: ChatAction, ) -> impl ChatActionFutureBounds<Output = Result<(), BotError>> + '_

Send a chat action to the specified channel

Source

fn action_expiry(&self) -> Duration

Duration after which the action indicator expires

Used for auto-renewal: renew at 80% of this duration.

Provided Methods§

Source

fn clear_action( &self, ) -> impl ChatActionFutureBounds<Output = Result<(), BotError>> + '_

Clear the indicator early

Called when the guard drops. Platforms that expire indicators on a timer (Discord, Telegram) need nothing here; Matrix uses it to retract the typing notice immediately.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§