Skip to main content

Channel

Trait Channel 

Source
pub trait Channel:
    Send
    + Sync
    + 'static {
    // Required methods
    fn name(&self) -> &'static str;
    fn reachable<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        db: &'life1 dyn Database,
        account_id: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<bool, ChannelError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn deliver<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        db: &'life1 dyn Database,
        account_id: &'life2 str,
        message: &'life3 ChannelMessage,
    ) -> Pin<Box<dyn Future<Output = Result<(), ChannelError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
}
Expand description

One extra delivery channel, registered next to the built-in push and email through crate::Notifications::channel (issue #764).

The module owns everything around the send — preference gates, the outbox, retries, dead letters — and the implementation owns exactly one thing: how a message reaches one account. Its name is written into the outbox payload and matched again in the drain, so it must be stable across deploys.

Required Methods§

Source

fn name(&self) -> &'static str

The channel’s stable, lower-case name — "telegram" — as it is written into outbox payloads and dead-letter reasons. One row per name: registering two channels with the same name is refused at composition time.

Source

fn reachable<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, db: &'life1 dyn Database, account_id: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<bool, ChannelError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Whether this account can be reached on this channel at all — an account that has linked one, say. Checked when the notification is enqueued and again immediately before sending: an answer that changed in between must still win.

An Err is the same as Ok(false) for the enqueue decision, and takes its own outcome in the drain.

Source

fn deliver<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, db: &'life1 dyn Database, account_id: &'life2 str, message: &'life3 ChannelMessage, ) -> Pin<Box<dyn Future<Output = Result<(), ChannelError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Delivers one message to this account. Called from the drain, once per outbox row; the outcome decides what happens to the row.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§