Skip to main content

SlackTransport

Trait SlackTransport 

Source
pub trait SlackTransport: Send + Sync {
    // Required methods
    fn post_message<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        channel: &'life1 str,
        text: &'life2 str,
        approval_id: &'life3 str,
    ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             Self: 'async_trait;
    fn next_event<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Option<SlackInboundEvent>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
}
Expand description

The Slack transport seam (MC-12 / MC-13). The production impl drives a Socket Mode WebSocket + the Web API; tests substitute a mock that captures outbound posts and injects inbound events.

Object-safe (#[async_trait]) so the adapter holds Arc<dyn SlackTransport> and the mock and real impls are interchangeable.

Required Methods§

Source

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

Post a Block Kit approval message carrying Approve/Deny buttons whose value is the approval_id. text is the human-readable summary (also carries the shared fan-out code for MC-8 equality). Returns the posted message ts on success.

Source

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

Block until the next inbound Slack event (button click or DM), or None when the source is exhausted / cancelled. The adapter ACKs and dispatches each returned event. The transport is responsible for the Socket Mode ACK contract and for suppressing the bot’s own echo (returning SlackInboundEvent::Ignore or skipping it).

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§