Skip to main content

ChannelAdapter

Trait ChannelAdapter 

Source
pub trait ChannelAdapter: Send + Sync {
    // Required methods
    fn provider_name(&self) -> &str;
    fn start<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = CiabResult<Receiver<InboundMessage>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn send<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        recipient_id: &'life1 str,
        content: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = CiabResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn state(&self) -> ChannelState;
    fn shutdown<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = CiabResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn qr_code(&self) -> Option<String> { ... }
}
Expand description

Adapter trait for messaging platform integrations.

Required Methods§

Source

fn provider_name(&self) -> &str

Human-readable provider name (e.g. “whatsapp”, “slack”, “webhook”).

Source

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

Start the adapter and return a receiver for inbound messages.

Source

fn send<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, recipient_id: &'life1 str, content: &'life2 str, ) -> Pin<Box<dyn Future<Output = CiabResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Send a message back to the platform.

Source

fn state(&self) -> ChannelState

Current adapter state.

Source

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

Gracefully shut down the adapter.

Provided Methods§

Source

fn qr_code(&self) -> Option<String>

QR code data (WhatsApp pairing).

Implementors§