pub trait Channel: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn start<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Receiver<IncomingMessage>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn send<'life0, 'async_trait>(
&'life0 self,
message: OutgoingMessage,
) -> Pin<Box<dyn Future<Output = Result<Option<String>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn stop<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn send_typing<'life0, 'life1, 'async_trait>(
&'life0 self,
_chat_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn send_media<'life0, 'async_trait>(
&'life0 self,
media: OutgoingMedia,
) -> Pin<Box<dyn Future<Output = Result<Option<String>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn supports_media(&self) -> bool { ... }
fn edit<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_chat_id: &'life1 str,
_message_id: &'life2 str,
_new_text: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait { ... }
fn as_draft(&self) -> Option<&dyn DraftChannel> { ... }
}Expand description
The core Channel trait. Implement for each messaging platform (Telegram, Discord, CLI, WebSocket, etc.)
Required Methods§
Sourcefn start<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Receiver<IncomingMessage>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn start<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Receiver<IncomingMessage>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Start receiving messages. Returns a receiver for incoming messages.
Provided Methods§
Sourcefn send_typing<'life0, 'life1, 'async_trait>(
&'life0 self,
_chat_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn send_typing<'life0, 'life1, 'async_trait>(
&'life0 self,
_chat_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Send a typing indicator (or equivalent) to the user.
Sourcefn send_media<'life0, 'async_trait>(
&'life0 self,
media: OutgoingMedia,
) -> Pin<Box<dyn Future<Output = Result<Option<String>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn send_media<'life0, 'async_trait>(
&'life0 self,
media: OutgoingMedia,
) -> Pin<Box<dyn Future<Output = Result<Option<String>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Send an attachment.
The default errors rather than silently degrading to a text message with a URL in it: a caller that asked for a picture and got a link back has been lied to. Channels that can carry media override this.
Sourcefn supports_media(&self) -> bool
fn supports_media(&self) -> bool
Whether send_media will do anything for this channel. Callers that can
fall back to text should check this instead of sending and catching.
Sourcefn edit<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_chat_id: &'life1 str,
_message_id: &'life2 str,
_new_text: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn edit<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_chat_id: &'life1 str,
_message_id: &'life2 str,
_new_text: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Edit a previously sent message if the channel supports it.
Sourcefn as_draft(&self) -> Option<&dyn DraftChannel>
fn as_draft(&self) -> Option<&dyn DraftChannel>
Live draft support, if this channel implements it.
Returning Some is the only way to opt into draft delivery, and
DraftChannel has no default methods, so opting in forces a real
finalize_draft.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".