pub struct TelegramPlatform { /* private fields */ }Implementations§
Source§impl TelegramPlatform
impl TelegramPlatform
Sourcepub fn new(token: String) -> Self
pub fn new(token: String) -> Self
Production constructor: official Telegram API base URL, 1 msg/s per-chat rate limit.
Sourcepub fn with_options(
token: String,
base_url: String,
rate_limit_interval: Duration,
) -> Self
pub fn with_options( token: String, base_url: String, rate_limit_interval: Duration, ) -> Self
Test/advanced constructor: override the base URL (a local HTTP stub) and/or the rate-limit interval (kept tiny in tests so a rate-limit-blocks assertion doesn’t need a real second-plus sleep).
Trait Implementations§
Source§impl Platform for TelegramPlatform
impl Platform for TelegramPlatform
Source§fn name(&self) -> &str
fn name(&self) -> &str
Short identifier, e.g.
"telegram". Matches InboundMessage::platform.Source§fn capabilities(&self) -> Capabilities
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,
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,
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,
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 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,
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).Auto Trait Implementations§
impl !Freeze for TelegramPlatform
impl !RefUnwindSafe for TelegramPlatform
impl !UnwindSafe for TelegramPlatform
impl Send for TelegramPlatform
impl Sync for TelegramPlatform
impl Unpin for TelegramPlatform
impl UnsafeUnpin for TelegramPlatform
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more