Expand description
RAII typing indicator guard.
TypingGuard automatically cancels the “typing…” chat action when
dropped, eliminating the need to remember to call send_chat_action
with SendMessageAction::SendMessageCancelAction manually.
§Example
use layer_client::{Client, TypingGuard};
use layer_tl_types as tl;
async fn handle(client: Client, peer: tl::enums::Peer) {
// Typing indicator is sent immediately and auto-cancelled on drop.
let _typing = TypingGuard::start(&client, peer.clone(),
tl::enums::SendMessageAction::SendMessageTypingAction).await.unwrap();
do_expensive_work().await;
// `_typing` is dropped here — Telegram sees the typing stop.
}Structs§
- Typing
Guard - Scoped typing indicator. Keeps the action alive by re-sending it every ~4 seconds (Telegram drops the indicator after ~5 s).