Skip to main content

Channel

Trait Channel 

Source
pub trait Channel: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn start<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Receiver<IncomingMessage>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn send<'life0, 'life1, 'async_trait>(
        &'life0 self,
        msg: &'life1 OutgoingMessage,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn health_check<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn ack_interaction<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _callback_query_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

The core channel trait. All external interfaces implement this.

Required Methods§

Source

fn name(&self) -> &str

Human-readable channel name.

Source

fn start<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Receiver<IncomingMessage>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Start listening for incoming messages. Returns a receiver that the engine polls.

Source

fn send<'life0, 'life1, 'async_trait>( &'life0 self, msg: &'life1 OutgoingMessage, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Send a message to a thread/conversation.

Source

fn health_check<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Check if this channel is healthy/connected.

Provided Methods§

Source

fn ack_interaction<'life0, 'life1, 'async_trait>( &'life0 self, _callback_query_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Acknowledge an interactive callback to dismiss the loading indicator.

Telegram requires answerCallbackQuery to dismiss the spinner after a button press. Discord buttons are already acknowledged in the websocket handler — no-op here. Default implementation is a no-op so non-interactive channels need not implement it.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§