Skip to main content

SendCallback

Trait SendCallback 

Source
pub trait SendCallback: Send + Sync {
    // Provided methods
    fn on_pending(&self, _chat_id: &str, _msg: &Message) { ... }
    fn on_upload_progress(
        &self,
        _pending_id: &str,
        _percentage: u8,
        _bytes_sent: u64,
    ) -> Result<(), String> { ... }
    fn on_upload_complete(
        &self,
        _chat_id: &str,
        _pending_id: &str,
        _attachment_id: &str,
        _url: &str,
    ) { ... }
    fn on_sent(&self, _chat_id: &str, _old_id: &str, _msg: &Message) { ... }
    fn on_failed(&self, _chat_id: &str, _old_id: &str, _msg: &Message) { ... }
    fn on_persist(&self, _chat_id: &str, _msg: &Message) { ... }
}
Expand description

Callbacks invoked during the DM send pipeline.

Each method has a default no-op so simple callers (CLI, bots, tests) implement only what they need. Methods are synchronous and non-fallible by design — they should never block the send pipeline.

Exception: on_upload_progress returns Result — return Err to cancel.

Provided Methods§

Source

fn on_pending(&self, _chat_id: &str, _msg: &Message)

Message created and added to STATE as pending.

Source

fn on_upload_progress( &self, _pending_id: &str, _percentage: u8, _bytes_sent: u64, ) -> Result<(), String>

File upload progress. Return Err(“…”) to cancel the upload.

Source

fn on_upload_complete( &self, _chat_id: &str, _pending_id: &str, _attachment_id: &str, _url: &str, )

Upload complete, attachment URL now available.

Source

fn on_sent(&self, _chat_id: &str, _old_id: &str, _msg: &Message)

Message successfully delivered to at least one relay. old_id is the pending ID, msg has the real event ID.

Source

fn on_failed(&self, _chat_id: &str, _old_id: &str, _msg: &Message)

Message delivery failed after all retry attempts.

Source

fn on_persist(&self, _chat_id: &str, _msg: &Message)

Persist message to database. Default is no-op. Tauri implements this to call save_message + save_slim_chat.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§