pub trait PlatformAdapter:
Send
+ Sync
+ 'static {
// Required methods
fn capabilities() -> PlatformCaps;
fn send_message<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
chat_id: &'life1 str,
text: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<SendResult>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn recv_event<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<PlatformEvent>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn edit_message<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
chat_id: &'life1 str,
_msg_id: &'life2 str,
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 upload_file<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_chat_id: &'life1 str,
_file_path: &'life2 str,
_media_type: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<UploadResult>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait { ... }
fn send_media_message<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
chat_id: &'life1 str,
file_url: &'life2 str,
file_name: &'life3 str,
media_type: &'life4 str,
) -> Pin<Box<dyn Future<Output = Result<SendResult>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait { ... }
}Expand description
The trait every chat platform must implement.
Connection lifecycle (WebSocket/HTTP setup, auth, background tasks) is the
platform crate’s responsibility — it constructs a connected adapter and
hands it to ChatbotManager as an
Arc<Self>. This avoids the tension between a connect() -> Self trait
method and adapters that spawn background tasks holding Arc<Self>.
Required Methods§
Sourcefn capabilities() -> PlatformCaps
fn capabilities() -> PlatformCaps
Platform capabilities. Used by ChatbotFrontend for streaming strategy
and by the Markdown sanitizer.
Sourcefn send_message<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
chat_id: &'life1 str,
text: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<SendResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn send_message<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
chat_id: &'life1 str,
text: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<SendResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Send a text message to a chat. Returns the platform message ID.
Sourcefn recv_event<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<PlatformEvent>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn recv_event<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<PlatformEvent>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Receive the next platform event. Blocks until an event arrives.
Provided Methods§
Sourcefn edit_message<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
chat_id: &'life1 str,
_msg_id: &'life2 str,
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_message<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
chat_id: &'life1 str,
_msg_id: &'life2 str,
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. Default implementation falls back
to send_message for platforms that don’t support editing.
Sourcefn upload_file<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_chat_id: &'life1 str,
_file_path: &'life2 str,
_media_type: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<UploadResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn upload_file<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_chat_id: &'life1 str,
_file_path: &'life2 str,
_media_type: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<UploadResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Upload a file to the platform. Returns the platform file URL/ID that can be referenced in subsequent messages.
file_path is a local filesystem path to the file.
media_type is a hint: “image” or “file”.
The default implementation returns an error — platforms that don’t support file uploads can keep the default.
Sourcefn send_media_message<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
chat_id: &'life1 str,
file_url: &'life2 str,
file_name: &'life3 str,
media_type: &'life4 str,
) -> Pin<Box<dyn Future<Output = Result<SendResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
fn send_media_message<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
chat_id: &'life1 str,
file_url: &'life2 str,
file_name: &'life3 str,
media_type: &'life4 str,
) -> Pin<Box<dyn Future<Output = Result<SendResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Send a media message (image/file) to a chat. Default implementation
falls back to send_message with the URL as text.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".