Skip to main content

Channel

Trait Channel 

Source
pub trait Channel: Send + Sync {
    // Required methods
    fn platform(&self) -> Platform;
    fn send<'life0, 'async_trait>(
        &'life0 self,
        msg: OutgoingMessage,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn receive<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<IncomingMessage>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn connect<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn disconnect<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Trait for messaging platform integrations (WebChat, Telegram, Discord, etc.).

Required Methods§

Source

fn platform(&self) -> Platform

Which platform this channel connects to.

Source

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

Send a message through this channel.

Source

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

Receive the next incoming message (blocks until available).

Source

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

Establish the connection to the platform.

Source

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

Gracefully disconnect.

Implementors§