Skip to main content

Platform

Trait Platform 

Source
pub trait Platform: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn capabilities(&self) -> Capabilities;
    fn start<'life0, 'async_trait>(
        &'life0 self,
        inbound: Sender<Inbound>,
    ) -> Pin<Box<dyn Future<Output = PlatformResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn reply<'life0, 'life1, 'async_trait>(
        &'life0 self,
        ctx: &'life1 ReplyCtx,
        msg: OutboundMessage,
    ) -> Pin<Box<dyn Future<Output = PlatformResult<MessageRef>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn edit<'life0, 'life1, 'async_trait>(
        &'life0 self,
        msg_ref: &'life1 MessageRef,
        new: OutboundMessage,
    ) -> Pin<Box<dyn Future<Output = PlatformResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn stop<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = PlatformResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

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

An IM-platform adapter. cc-connect’s proven 5-method core (start, reply, edit, stop, plus capabilities/name) — see epic #447.

Required Methods§

Source

fn name(&self) -> &str

Short identifier, e.g. "telegram". Matches InboundMessage::platform.

Source

fn capabilities(&self) -> Capabilities

What this adapter supports.

Source

fn start<'life0, 'async_trait>( &'life0 self, inbound: Sender<Inbound>, ) -> Pin<Box<dyn Future<Output = PlatformResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Start receiving inbound events (messages and/or button presses), sending each onto inbound. Runs for the adapter’s lifetime (a long-poll loop, a WS connection, …); returns only on an unrecoverable error or stop().

Source

fn reply<'life0, 'life1, 'async_trait>( &'life0 self, ctx: &'life1 ReplyCtx, msg: OutboundMessage, ) -> Pin<Box<dyn Future<Output = PlatformResult<MessageRef>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Send a message in reply to ctx.

Source

fn edit<'life0, 'life1, 'async_trait>( &'life0 self, msg_ref: &'life1 MessageRef, new: OutboundMessage, ) -> Pin<Box<dyn Future<Output = PlatformResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Edit a previously-sent message in place. Capability-gated on Capabilities::edit_message; adapters that don’t support it may return an error — callers must check the capability first.

Source

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

Stop the adapter (best-effort; graceful shutdown).

Provided Methods§

Source

fn answer_callback<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _callback_query_id: &'life1 str, _text: Option<&'life2 str>, ) -> Pin<Box<dyn Future<Output = PlatformResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Acknowledge a callback query (capability-gated on Capabilities::buttons — adapters without button support never receive one to acknowledge, so the default no-op is correct for them). Telegram requires exactly one ack per callback query, success or not; text, when Some, is shown as a brief toast (e.g. an “expired” notice for a stale/forged nonce).

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§