Skip to main content

ChannelAdapter

Trait ChannelAdapter 

Source
pub trait ChannelAdapter: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn chat_type_routes(&self) -> Vec<(&str, ConversationKind)>;
    fn send_text<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        external_chat_id: &'life1 str,
        text: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;

    // Provided methods
    fn is_local_only(&self) -> bool { ... }
    fn allows_cross_chat(&self) -> bool { ... }
    fn text_chunk_limit_bytes(&self) -> Option<usize> { ... }
    fn text_chunk_delay(&self) -> Option<Duration> { ... }
    fn send_text_chunk<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        external_chat_id: &'life1 str,
        text: &'life2 str,
        _idempotency_key: &'life3 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait { ... }
    fn send_attachment<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        _external_chat_id: &'life1 str,
        _file_path: &'life2 Path,
        _caption: Option<&'life3 str>,
    ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait { ... }
}

Required Methods§

Source

fn name(&self) -> &str

Unique name: “telegram”, “discord”, “slack”, “web”

Source

fn chat_type_routes(&self) -> Vec<(&str, ConversationKind)>

DB chat_type strings this adapter handles + whether each is private/group.

Source

fn send_text<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, external_chat_id: &'life1 str, text: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Send text to external chat. Called by deliver_and_store_bot_message.

Provided Methods§

Source

fn is_local_only(&self) -> bool

Whether this channel stores messages only (no external delivery). Web = true.

Source

fn allows_cross_chat(&self) -> bool

Whether chats on this channel can operate on other chats. Web = false.

Source

fn text_chunk_limit_bytes(&self) -> Option<usize>

Maximum UTF-8 byte length for one native text item. When present, the shared delivery pipeline persists and sends chunks independently.

Source

fn text_chunk_delay(&self) -> Option<Duration>

Optional pacing between consecutive chunks of one logical message.

Source

fn send_text_chunk<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, external_chat_id: &'life1 str, text: &'life2 str, _idempotency_key: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Send one already-split chunk. Channels with native idempotency support should use idempotency_key as their request/client message id.

Source

fn send_attachment<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, _external_chat_id: &'life1 str, _file_path: &'life2 Path, _caption: Option<&'life3 str>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Send file attachment. Default: not supported.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§