Skip to main content

Client

Struct Client 

Source
pub struct Client { /* private fields */ }
Expand description

The main Telegram client. Cheap to clone: internally Arc-wrapped.

Implementations§

Source§

impl Client

Source

pub async fn bot_sign_in(&self, token: &str) -> Result<String, InvocationError>

Sign in as a bot.

Source

pub async fn request_login_code( &self, phone: &str, ) -> Result<LoginToken, InvocationError>

Request a login code for a user account.

Source

pub async fn sign_in( &self, token: &LoginToken, code: &str, ) -> Result<String, SignInError>

Complete sign-in with the code sent to the phone.

Source

pub async fn check_password( &self, token: PasswordToken, password: impl AsRef<[u8]>, ) -> Result<String, InvocationError>

Complete 2FA login.

Source

pub async fn sign_out(&self) -> Result<bool, InvocationError>

Sign out and invalidate the current session.

Source

pub async fn get_users_by_id( &self, ids: &[i64], ) -> Result<Vec<Option<User>>, InvocationError>

Fetch user info by ID. Returns None for each ID that is not found.

Used internally by update::IncomingMessage::sender_user.

Source

pub async fn get_user_from_message( &self, peer: InputPeer, msg_id: i32, user_id: i64, ) -> Result<Option<User>, InvocationError>

Resolve a user by message context (no access_hash required). Returns None if Telegram returns no matching user.

Source

pub fn my_id(&self) -> Option<i64>

The logged-in account’s numeric user ID, if already known.

This is a cheap, synchronous, no-network lookup of a value captured automatically the first time a User object with is_self == true was cached (sign-in, get_me(), etc.). Returns None only if neither has happened yet in this session - call my_id_or_fetch() for a version that falls back to a network call in that case.

Source

pub async fn my_id_or_fetch(&self) -> Result<i64, InvocationError>

Like my_id, but performs a one-time get_me() call to populate the cache if it isn’t already known.

Source

pub async fn get_me(&self) -> Result<User, InvocationError>

Fetch information about the logged-in user.

Source

pub async fn export_login_token( &self, ) -> Result<(Vec<u8>, i32), InvocationError>

Generate a QR-code login token.

Returns (token_bytes, expires_unix_ts). Encode token_bytes as a tg://login?token=<base64url> URL and present as a QR code.

Call import_qr_token once the user scans it, then poll until you receive Update::Raw with updateLoginToken (constructor 0x564fe691), or call export_login_token again to check.

§Example
let (token, expires) = client.export_login_token().await?;
// base64url-encode `token` and make a QR code
Source

pub async fn check_qr_login( &self, token: Vec<u8>, ) -> Result<Option<String>, InvocationError>

Check whether a QR-code token has been scanned.

Returns Some(username) if the user has scanned and confirmed the QR code, or None if still pending.

Source§

impl Client

Source

pub async fn open_mini_app( &self, peer: impl Into<PeerRef>, app: MiniApp, ) -> Result<MiniAppSession, InvocationError>

Open a Telegram Mini App (a web app) in peer’s context and get back a session you can use to interact with it. app picks whether you’re opening the bot’s main app or a specific URL it registered.

Source

pub async fn answer_callback_query( &self, query_id: i64, text: Option<&str>, alert: bool, ) -> Result<bool, InvocationError>

Respond to a button tap from an inline keyboard. With alert: true, text shows as a popup the user has to dismiss; otherwise it’s a brief toast. You should call this for every callback query you get, even with no text, or the button stays stuck in a loading state.

Source

pub async fn answer_inline_query( &self, query_id: i64, results: Vec<InputBotInlineResult>, cache_time: i32, is_personal: bool, next_offset: Option<String>, ) -> Result<bool, InvocationError>

Send results back for an @your_bot query inline query. next_offset lets the client ask for more results when the user scrolls, by passing it back to you as the next query’s offset.

Source

pub async fn start_bot( &self, bot_user_id: i64, peer: impl Into<PeerRef>, start_param: impl Into<String>, ) -> Result<(), InvocationError>

Send /start to a bot with a deep-link parameter, as if the user tapped a t.me/bot?start=... link.

Source

pub async fn set_game_score( &self, peer: impl Into<PeerRef>, msg_id: i32, user_id: i64, score: i32, force: bool, edit_message: bool, ) -> Result<(), InvocationError>

Set a user’s score for the game in a sent game message. With force: true, the score is set even if it’s lower than the user’s current one; with edit_message: true, the message’s scoreboard is updated in place.

Source

pub async fn get_game_high_scores( &self, peer: impl Into<PeerRef>, msg_id: i32, user_id: i64, ) -> Result<Vec<HighScore>, InvocationError>

Get the high score table for the game in a sent game message, centered around user_id.

Source

pub async fn edit_inline_message( &self, id: InputBotInlineMessageId, new_text: &str, reply_markup: Option<ReplyMarkup>, ) -> Result<bool, InvocationError>

Edit a message that was sent via inline mode (one identified by an InputBotInlineMessageId, not a regular message ID).

Source

pub async fn set_bot_commands( &self, commands: &[(&str, &str)], scope: Option<BotCommandScope>, lang_code: &str, ) -> Result<bool, InvocationError>

Set the bot’s command list - the menu users see when they tap the / icon. scope controls where it applies (everywhere, a specific chat, just admins, etc); None means the default scope.

Source

pub async fn delete_bot_commands( &self, scope: Option<BotCommandScope>, lang_code: &str, ) -> Result<bool, InvocationError>

Clear the bot’s command list for a scope, falling back to whatever the next broader scope defines.

Source

pub async fn set_bot_info( &self, bot: Option<impl Into<PeerRef>>, name: Option<&str>, about: Option<&str>, description: Option<&str>, lang_code: &str, ) -> Result<bool, InvocationError>

Set bot profile info.

bot: pass the bot’s peer when calling from a userbot that owns the bot. Pass None when calling from the bot session itself.

All text fields are optional; only the ones you supply are changed.

§Examples
// From a bot session: edit self.
client.set_bot_info(None::<&str>, Some("My Bot"), Some("Short about."), Some("Start page text."), "en").await?;

// From a userbot: edit an owned bot.
client.set_bot_info(Some("@MyBot"), Some("My Bot"), None, None, "en").await?;
Source

pub async fn get_bot_info( &self, bot: Option<impl Into<PeerRef>>, lang_code: &str, ) -> Result<BotInfo, InvocationError>

Get bot profile info.

bot: pass the bot’s peer when calling from a userbot. Pass None when calling from the bot session itself.

Source§

impl Client

Source

pub async fn delete_chat( &self, peer: impl Into<PeerRef>, ) -> Result<(), InvocationError>

Delete a chat or channel. Dispatches to channels.deleteChannel for channels/supergroups and messages.deleteChat for legacy basic groups.

Only the creator can delete. This action is irreversible.

Source

pub async fn leave_chat( &self, peer: impl Into<PeerRef>, ) -> Result<(), InvocationError>

Leave a channel or supergroup.

For basic groups, kick yourself or use Client::delete_dialog to just hide it.

Source

pub async fn migrate_chat(&self, chat_id: i64) -> Result<Chat, InvocationError>

Upgrade a legacy group to a supergroup (megagroup).

Returns the new channel/supergroup peer. The original chat ID becomes invalid after migration.

Source

pub async fn get_chat_full( &self, peer: impl Into<PeerRef>, ) -> Result<ChatFull, InvocationError>

Get the full info for a chat - description, pinned message, slow-mode delay, and other fields the basic chat object doesn’t carry.

Source

pub async fn delete_chat_history( &self, peer: impl Into<PeerRef>, max_id: i32, revoke: bool, ) -> Result<(), InvocationError>

Delete messages up to max_id from a chat’s history on your side. With revoke: true on a group/channel you admin, it deletes for everyone instead of just you.

Source

pub async fn create_group( &self, title: impl Into<String>, user_ids: Vec<i64>, ) -> Result<Chat, InvocationError>

Create a basic group chat with title and the given members. This is the small, old-style group with a low member cap - use Self::create_channel for a supergroup if you need more room or admin tooling.

Source

pub async fn create_channel( &self, title: impl Into<String>, about: impl Into<String>, broadcast: bool, ) -> Result<Chat, InvocationError>

Create a channel or supergroup. broadcast: true makes a broadcast channel (only admins post); false makes a supergroup (everyone can, by default).

Source

pub async fn edit_chat_default_banned_rights( &self, peer: impl Into<PeerRef>, build: impl FnOnce(BannedRightsBuilder) -> BannedRightsBuilder, ) -> Result<(), InvocationError>

Set the default permissions for non-admin members of a chat, using a builder closure over crate::participants::BannedRightsBuilder.

Source

pub async fn invite_users( &self, peer: impl Into<PeerRef>, user_ids: &[i64], ) -> Result<(), InvocationError>

Add one or more users to a chat by user ID.

Source

pub async fn set_history_ttl( &self, peer: impl Into<PeerRef>, period: i32, ) -> Result<(), InvocationError>

Set the auto-delete timer for new messages in a chat, in seconds. Pass 0 to turn it off.

Source

pub async fn get_common_chats( &self, user_id: i64, max_id: i64, limit: i32, ) -> Result<Vec<Chat>, InvocationError>

List the group chats you have in common with a user. max_id/limit page through results if there are a lot.

Source

pub async fn get_chat_administrators( &self, peer: impl Into<PeerRef>, ) -> Result<Vec<Participant>, InvocationError>

List the admins of a chat.

Source

pub async fn transfer_chat_ownership( &self, peer: impl Into<PeerRef>, new_owner_id: i64, password: InputCheckPasswordSrp, ) -> Result<(), InvocationError>

Transfer ownership of a channel or supergroup to another user. You’ll need their confirmation on Telegram’s end too - this just starts the transfer. password is your 2FA password, required by Telegram for this regardless of whether you’d normally need it to log in.

Source

pub async fn get_linked_channel( &self, peer: impl Into<PeerRef>, ) -> Result<Option<i64>, InvocationError>

Get the ID of the discussion group linked to a broadcast channel, or None if it doesn’t have one.

Source

pub async fn get_admin_log( &self, peer: impl Into<PeerRef>, query: impl Into<String>, limit: i32, max_id: i64, min_id: i64, ) -> Result<Vec<ChannelAdminLogEvent>, InvocationError>

Read the admin action log for a supergroup or channel: who banned who, what got deleted, title changes, and so on. You need to be an admin of peer to call this. query filters by text, and max_id/min_id page through results - pass 0 for both to start from the most recent event.

Source

pub async fn toggle_no_forwards( &self, peer: impl Into<PeerRef>, enabled: bool, ) -> Result<(), InvocationError>

Turn content protection on or off for a chat - when enabled, members can’t forward or save media from it.

Source

pub async fn set_chat_theme( &self, peer: impl Into<PeerRef>, emoticon: impl Into<String>, ) -> Result<(), InvocationError>

Set the emoji theme for a chat. emoticon must be one of the emoji Telegram’s official clients offer in the chat theme picker, not arbitrary text.

Source

pub async fn set_chat_reactions( &self, peer: impl Into<PeerRef>, reactions: ChatReactions, ) -> Result<(), InvocationError>

Set which reactions are allowed in a chat - all of them, none, or a specific list.

Source

pub async fn get_send_as_peers( &self, peer: impl Into<PeerRef>, ) -> Result<Vec<Peer>, InvocationError>

List the identities you can post as in a chat - your own account, or any channel you admin that’s linked to it.

Source

pub async fn set_default_send_as( &self, peer: impl Into<PeerRef>, send_as_peer: impl Into<PeerRef>, ) -> Result<(), InvocationError>

Set which identity you post as in a chat by default, from the options Self::get_send_as_peers returns.

Source§

impl Client

Source

pub async fn get_dialogs( &self, limit: i32, ) -> Result<Vec<Dialog>, InvocationError>

Fetch up to limit dialogs, most recent first. Populates entity/message.

Source

pub async fn delete_dialog( &self, peer: impl Into<PeerRef>, ) -> Result<(), InvocationError>

Remove a dialog from your chat list, clearing its history on your side. For a group or channel this also makes you leave it.

Source

pub async fn mark_read( &self, peer: impl Into<PeerRef>, ) -> Result<(), InvocationError>

Mark all messages in a chat as read.

Source

pub async fn clear_mentions( &self, peer: impl Into<PeerRef>, ) -> Result<(), InvocationError>

Clear unread mention markers.

Source

pub async fn join_chat( &self, peer: impl Into<PeerRef>, ) -> Result<(), InvocationError>

Join a public chat or channel by username/peer.

Source

pub fn parse_invite_hash(link: &str) -> Option<&str>

Extract hash from https://t.me/+HASH or https://t.me/joinchat/HASH.

Source

pub fn iter_dialogs(&self) -> DialogIter

Returns a DialogIter that can be advanced with DialogIter::next. Lets you page through all dialogs without loading them all at once.

§Example
let mut iter = client.iter_dialogs();
while let Some(dialog) = iter.next(&client).await? {
println!("{}", dialog.title());
}
Source

pub fn iter_messages(&self, peer: impl Into<PeerRef>) -> MessageIter

Fetch messages from a peer, page by page.

Returns a MessageIter that can be advanced with MessageIter::next.

§Example
let mut iter = client.iter_messages(peer);
while let Some(msg) = iter.next(&client).await? {
println!("{:?}", msg.text());
}
Source

pub async fn sync_drafts(&self) -> Result<(), InvocationError>

Fetch all saved drafts across all chats.

The server responds with an Updates containing updateDraftMessage entries; this method triggers that push and returns immediately.

Source

pub async fn clear_all_drafts(&self) -> Result<(), InvocationError>

Delete all saved drafts across all chats.

Source

pub async fn pin_dialog( &self, peer: impl Into<PeerRef>, pin: bool, ) -> Result<(), InvocationError>

Pin or unpin a dialog. pin: true pins, pin: false unpins.

Source

pub async fn archive( &self, peer: impl Into<PeerRef>, archive: bool, ) -> Result<(), InvocationError>

Archive or unarchive a dialog. archive: true moves to folder 1 (archive), false moves back to folder 0.

Source

pub async fn get_pinned_dialogs( &self, folder_id: i32, ) -> Result<Vec<Dialog>, InvocationError>

List the pinned dialogs in a folder. folder_id is 0 for the main list, 1 for the Archive folder.

Source

pub async fn mark_dialog_unread( &self, peer: impl Into<PeerRef>, ) -> Result<(), InvocationError>

Mark a dialog as unread, the way “Mark as unread” in the app does - independent of whether it actually has unread messages.

Source§

impl Client

Source

pub async fn upload_sequential( &self, path: impl AsRef<Path>, handle: Option<&TransferHandle>, ) -> Result<UploadedFile, InvocationError>

Upload a file from disk one chunk at a time, without ever loading the full file into memory.

Reads and sends each part sequentially with no concurrency. RAM usage stays flat at roughly one chunk size regardless of how large the file is. Good for constrained environments or when you want predictable memory, but slower than upload_file on a fast connection.

MIME type is sniffed from the first bytes of the file so you do not need to specify it manually.

Pass a TransferHandle if you want to pause, resume, or cancel mid-transfer. Pass None to skip progress tracking entirely.

§Example
use ferogram::{Client, TransferHandle};

let handle = TransferHandle::new();
let uploaded = client.upload_sequential("big_video.mp4", Some(&handle)).await?;
// Then attach to a message:
// client.send_message(chat, InputMessage::text("").document(uploaded)).await?;
Source

pub async fn download( &self, media: &MessageMedia, dest: impl AsyncWrite + Unpin, handle: Option<&TransferHandle>, ) -> Result<u64, InvocationError>

Download message media to any writable sink: a Vec<u8>, a file handle, a socket, etc.

Streams data directly to dest without buffering the entire file in memory first. Returns the total number of bytes written.

If the media is on a different DC than the current connection, ferogram reconnects transparently. You do not need to handle DC switching yourself.

Pass a TransferHandle to track progress, pause, or cancel. Pass None to skip progress tracking.

§Example
// Download to an in-memory buffer
let mut buf = Vec::new();
client.download(msg.media().unwrap(), &mut buf, None).await.unwrap();

// Stream directly to a file on disk
let mut file = tokio::fs::File::create("photo.jpg").await.unwrap();
client.download(msg.media().unwrap(), &mut file, None).await.unwrap();
Source

pub fn download_file<'a>( &'a self, media: &'a MessageMedia, path: impl AsRef<Path>, ) -> DownloadFile<'a>

Download message media and save it directly to a file at path.

Creates the file if it does not exist, or truncates it if it does. Data is streamed to disk without loading everything into memory first.

For large files (over 10 MB) this uses concurrent workers automatically, which is significantly faster than the sequential path. You do not need to configure anything; ferogram picks the worker count based on file size.

Returns the number of bytes written.

By default no progress tracking happens. Chain .handle(&handle) before .await if you want to track progress, pause, or cancel the transfer:

let handle = TransferHandle::new();
client.download_file(msg.media().unwrap(), "downloaded.mp4")
    .handle(&handle)
    .await?;
§Example
client.download_file(msg.media().unwrap(), "downloaded.mp4").await?;
Source

pub fn iter_download(&self, media: &MessageMedia) -> Option<DownloadIter>

Return a lazy chunk iterator for media.

Useful when you want to process file bytes as they arrive instead of waiting for the full download to complete. Each call to DownloadIter::next fetches the next chunk from Telegram and returns it as a bytes::Bytes slice.

Returns None if the media does not have a downloadable location (for example, a contact card or a venue).

§Example
if let Some(mut iter) = client.iter_download(msg.media().unwrap()) {
    while let Some(chunk) = iter.next().await? {
        // process chunk bytes
    }
}
Source

pub fn upload<'a, R>(&'a self, source: R, name: &str) -> Upload<'a, R>
where R: AsyncRead + Unpin + Send + 'a,

Upload from any tokio::io::AsyncRead source: a file handle, a network stream, a cursor over bytes in memory, etc.

Reads the entire source into memory first, then uploads using the optimal part size. If the data is larger than 10 MB, concurrent workers are used automatically.

If you already have a path on disk, prefer upload_file instead. It stats the file before opening it and avoids the in-memory buffer for large files.

By default no progress tracking happens. Chain .handle(&handle) before .await if you want to track progress, pause, or cancel the transfer:

let handle = TransferHandle::new();
let bytes = b"hello world".to_vec();
let uploaded = client.upload(std::io::Cursor::new(bytes), "note.txt")
    .handle(&handle)
    .await?;
§Example
use ferogram::Client;

let bytes = b"hello world".to_vec();
let uploaded = client.upload(std::io::Cursor::new(bytes), "note.txt").await?;
Source

pub fn upload_file<'a>(&'a self, path: impl AsRef<Path>) -> UploadFile<'a>

Upload a file from disk by path. This is the standard upload method for most use cases.

Stats the file first so ferogram can pick the right part size without reading the entire file upfront. For large files (over 10 MB) it streams from disk with concurrent workers, keeping RAM usage low even for multi-gigabyte files.

For strict sequential uploads with a fixed memory ceiling, use upload_sequential.

MIME type is detected automatically from the file name and content.

By default no progress tracking happens. Chain .handle(&handle) before .await if you want to track progress, pause, or cancel the transfer:

let handle = TransferHandle::new();
let uploaded = client.upload_file("photo.jpg")
    .handle(&handle)
    .await?;
§Example
use ferogram::Client;

let uploaded = client.upload_file("photo.jpg").await?;
// Then send it as a photo:
// client.send_message(chat, InputMessage::text("").photo(uploaded)).await?;
Source

pub async fn get_media_group( &self, peer: impl Into<PeerRef>, msg_id: i32, ) -> Result<Vec<IncomingMessage>, InvocationError>

Get every message in the same media group (album) as msg_id, given any one message from that group.

Source§

impl Client

Source

pub async fn get_forum_topics( &self, peer: impl Into<PeerRef>, query: Option<String>, limit: i32, offset_date: i32, offset_id: i32, offset_topic: i32, ) -> Result<Vec<ForumTopic>, InvocationError>

List a forum group’s topics, optionally filtered by query. Page through results with offset_date/offset_id/offset_topic from the last topic you saw - all 0 to start from the most recent.

Source

pub async fn get_forum_topics_by_id( &self, peer: impl Into<PeerRef>, topic_ids: Vec<i32>, ) -> Result<Vec<ForumTopic>, InvocationError>

Look up specific topics in a forum group by their topic IDs.

Source

pub async fn create_forum_topic( &self, peer: impl Into<PeerRef>, title: impl Into<String>, icon_color: Option<i32>, icon_emoji_id: Option<i64>, ) -> Result<(), InvocationError>

Create a new topic in a forum group. icon_color/icon_emoji_id are both optional - leave them None for Telegram’s default icon.

Source

pub async fn edit_forum_topic( &self, peer: impl Into<PeerRef>, topic_id: i32, title: Option<String>, icon_emoji_id: Option<i64>, closed: Option<bool>, hidden: Option<bool>, ) -> Result<(), InvocationError>

Edit a topic’s title, icon, or open/closed and hidden state. Pass None for any field you don’t want to change.

Source

pub async fn delete_forum_topic_history( &self, peer: impl Into<PeerRef>, top_msg_id: i32, ) -> Result<(), InvocationError>

Delete every message in a topic. Telegram only deletes a batch at a time, so this keeps calling through until nothing’s left.

Source

pub async fn toggle_forum( &self, peer: impl Into<PeerRef>, enabled: bool, ) -> Result<(), InvocationError>

Turn Topics mode on or off for a supergroup.

Source§

impl Client

Create a new invite link for a chat. expire_date/usage_limit cap when it stops working; request_needed: true makes joins go through admin approval instead of being instant.

Revoke an invite link so it stops working.

Change an existing invite link’s expiry, usage limit, approval requirement, or title. Fields left None are unchanged.

List invite links for a chat created by a specific admin. Set revoked: true to see revoked links instead of active ones; offset_date/offset_link page through results.

Permanently delete a revoked invite link. Active links need Self::revoke_invite_link first.

Delete every revoked invite link a specific admin created for a chat, in one go.

Source

pub async fn join_request( &self, peer: impl Into<PeerRef>, user_id: i64, approve: bool, ) -> Result<(), InvocationError>

Approve or decline a single pending join request.

Source

pub async fn all_join_requests( &self, peer: impl Into<PeerRef>, approve: bool, link: Option<String>, ) -> Result<(), InvocationError>

Approve or decline every pending join request for a chat at once. Pass link to only act on requests that came through that specific invite link.

List the people who joined (or requested to join) through a chat’s invite links. Pass link to filter to one specific link, or None for all of them. Set requested: true to list pending join requests instead of people who already joined.

Source

pub async fn get_admins_with_invites( &self, peer: impl Into<PeerRef>, ) -> Result<ChatAdminsWithInvites, InvocationError>

List the admins who have invite links for a chat, with how many people joined through each admin’s links.

Source§

impl Client

Source

pub fn search(&self, peer: impl Into<PeerRef>, query: &str) -> SearchBuilder

Fluent search builder for in-chat message search.

Source

pub fn search_global(&self, query: &str) -> GlobalSearchBuilder

Fluent builder for global cross-chat search.

Source

pub async fn send_message( &self, peer: impl Into<PeerRef>, msg: impl Into<InputMessage>, ) -> Result<IncomingMessage, InvocationError>

Send a message to a peer.

If msg carries attached media (set via InputMessage::copy_media), this dispatches through messages.SendMedia instead of messages.SendMessage, since the latter has no media field and would silently drop it.

Source

pub async fn send_to_self( &self, msg: impl Into<InputMessage>, ) -> Result<IncomingMessage, InvocationError>

Send a message to your own Saved Messages. A quick way to test that a connection works, or to leave yourself a note.

Source

pub async fn edit_message( &self, peer: impl Into<PeerRef>, message_id: i32, new_text: impl Into<InputMessage>, ) -> Result<(), InvocationError>

Edit the text of an existing message.

Source

pub async fn forward_messages( &self, destination: impl Into<PeerRef>, message_ids: &[i32], source: impl Into<PeerRef>, opts: ForwardOptions, ) -> Result<Vec<IncomingMessage>, InvocationError>

Forward one or more messages from source to destination. Forwards keep the “Forwarded from” attribution by default; set opts to strip it or to reply to an existing message in the destination.

Source

pub async fn delete_messages( &self, message_ids: &[i32], revoke: bool, ) -> Result<(), InvocationError>

Delete messages by ID from a regular chat or DM. Channel posts need channel-aware deletion instead, which isn’t wired up on this path. With revoke: true, deletes for the other side too, not just you.

Source

pub async fn get_messages( &self, peer: impl Into<PeerRef>, ids: &[i32], ) -> Result<Vec<IncomingMessage>, InvocationError>

Fetch a single message by ID.

Source

pub async fn get_pinned_message( &self, peer: impl Into<PeerRef>, ) -> Result<Option<IncomingMessage>, InvocationError>

Get the currently pinned message in a chat, or None if nothing’s pinned. If a chat has multiple pins, this returns only the latest one.

Source

pub async fn pin_message( &self, peer: impl Into<PeerRef>, id: i32, pin: bool, ) -> Result<(), InvocationError>

Pin or unpin a message. pin: true pins, pin: false unpins.

Source

pub async fn unpin_all_messages( &self, peer: impl Into<PeerRef>, ) -> Result<(), InvocationError>

Unpin every pinned message in a chat at once.

Source

pub async fn get_scheduled_messages( &self, peer: impl Into<PeerRef>, ) -> Result<Vec<IncomingMessage>, InvocationError>

List a chat’s scheduled messages - the ones queued to send later, not sent yet.

Source

pub async fn delete_scheduled_messages( &self, peer: impl Into<PeerRef>, ids: &[i32], ) -> Result<(), InvocationError>

Cancel scheduled messages before they send.

Source

pub async fn get_message_history( &self, peer: impl Into<PeerRef>, limit: i32, offset_id: i32, add_offset: i32, ) -> Result<Vec<IncomingMessage>, InvocationError>

Fetch message history for a peer, newest first.

recent message). add_offset additionally skips this many messages past that anchor, which is what makes simple limit-based pagination possible without having to track the exact last-seen message ID yourself: e.g. get_message_history(peer, 20, 0, 0) for the first page, then get_message_history(peer, 20, 0, 20) for the second, add_offset: 40 for the third, and so on. The server still has to walk past the skipped messages internally, so this does not scale well to very deep pagination - prefer Client::iter_messages for walking large histories.

Source

pub async fn send_chat_action( &self, peer: impl Into<PeerRef>, action: SendMessageAction, ) -> Result<(), InvocationError>

Show a chat action like “typing…” in a chat. Telegram clears it automatically after a few seconds, so call this again if the action is still ongoing.

Source

pub async fn send_dice( &self, peer: impl Into<PeerRef>, emoticon: impl Into<String>, ) -> Result<IncomingMessage, InvocationError>

Send a dice/dart/basketball/etc animated emoji and return the sent message.

The rolled value is in the returned message’s media:

let msg = client.send_dice(123456789, "🎲").await?;
if let Some(tl::enums::MessageMedia::Dice(d)) = msg.media() {
    println!("rolled {}", d.value);
}
Source

pub async fn save_draft( &self, peer: impl Into<PeerRef>, text: impl Into<String>, ) -> Result<(), InvocationError>

Save text as the draft for a chat, the way an unsent typed message shows up when you reopen it.

Source

pub async fn send_scheduled_now( &self, peer: impl Into<PeerRef>, ids: &[i32], ) -> Result<(), InvocationError>

Send scheduled messages immediately instead of waiting for their scheduled time.

Source

pub async fn get_message_read_participants( &self, peer: impl Into<PeerRef>, msg_id: i32, ) -> Result<Vec<ReadParticipantDate>, InvocationError>

List who has read a message and when, in a small group. Telegram doesn’t track this for everything - large chats or old enough messages just come back empty.

Source

pub async fn get_replies( &self, peer: impl Into<PeerRef>, msg_id: i32, limit: i32, offset_id: i32, add_offset: i32, ) -> Result<Vec<IncomingMessage>, InvocationError>

Fetch replies in a discussion thread. Same add_offset pagination trick as Client::get_message_history: skip this many messages past offset_id (which can stay 0) to jump straight to a given page.

Source

pub async fn get_discussion_message( &self, peer: impl Into<PeerRef>, msg_id: i32, ) -> Result<DiscussionMessage, InvocationError>

Get the discussion-group message linked to a channel post, for channels that have comments enabled.

Source

pub async fn read_discussion( &self, peer: impl Into<PeerRef>, msg_id: i32, read_max_id: i32, ) -> Result<(), InvocationError>

Mark a discussion thread as read up to read_max_id.

Source

pub async fn get_web_page_preview( &self, text: impl Into<String>, ) -> Result<MessageMedia, InvocationError>

Generate a link preview for text without sending it anywhere - handy for showing a preview before the user actually sends.

Source

pub async fn translate_messages( &self, peer: impl Into<PeerRef>, msg_ids: Vec<i32>, to_lang: impl Into<String>, ) -> Result<Vec<TextWithEntities>, InvocationError>

Translate one or more existing messages to to_lang (an ISO language code like "en").

Source

pub async fn transcribe_audio( &self, peer: impl Into<PeerRef>, msg_id: i32, ) -> Result<TranscribedAudio, InvocationError>

Transcribe a voice message to text.

Source

pub async fn toggle_peer_translations( &self, peer: impl Into<PeerRef>, disabled: bool, ) -> Result<(), InvocationError>

Turn the “Translate” button on or off for a chat.

Get a t.me link to a specific message. kind picks whether it points at the single message, its whole media group, or its comment thread.

Source§

impl Client

Source

pub async fn answer_precheckout_query( &self, query_id: i64, ok: bool, error_message: Option<String>, ) -> Result<(), InvocationError>

Approve or decline a checkout right before payment is charged. Set ok: false with an error_message to tell the user why it can’t go through (e.g. out of stock).

Source

pub async fn answer_shipping_query( &self, query_id: i64, error: Option<String>, shipping_options: Option<Vec<ShippingOption>>, ) -> Result<(), InvocationError>

Respond to a shipping query with available shipping options, or an error if you can’t ship to the address the user gave.

Source

pub async fn send_invoice( &self, peer: impl Into<PeerRef>, title: impl Into<String>, description: impl Into<String>, payload: impl Into<String>, options: InvoiceOptions, ) -> Result<IncomingMessage, InvocationError>

Send a payment invoice message. payload is your own opaque string for tracking the order - it isn’t shown to the user.

Source§

impl Client

Source

pub async fn send_poll( &self, peer: impl Into<PeerRef>, poll: PollBuilder, ) -> Result<(), InvocationError>

Send a poll, built with crate::poll::PollBuilder.

Source

pub async fn send_vote( &self, peer: impl Into<PeerRef>, msg_id: i32, options: Vec<Vec<u8>>, ) -> Result<(), InvocationError>

Vote on a poll. options are the option byte identifiers from the poll’s own answer list, not their text or index - pass more than one only if the poll allows multiple choice.

Source

pub async fn poll_results( &self, peer: impl Into<PeerRef>, msg_id: i32, ) -> Result<PollStats, InvocationError>

Get statistics for a poll message.

Source

pub async fn get_poll_votes( &self, peer: impl Into<PeerRef>, msg_id: i32, option: Option<Vec<u8>>, limit: i32, offset: Option<String>, ) -> Result<VotesList, InvocationError>

List who voted for what on a poll. Pass option to filter to one specific answer, or None for everyone; offset/limit page through results.

Source§

impl Client

Source

pub async fn get_privacy( &self, key: InputPrivacyKey, ) -> Result<Vec<PrivacyRule>, InvocationError>

Get your privacy rules for one setting - who can see your phone number, add you to groups, call you, and so on.

Source

pub async fn set_privacy( &self, key: InputPrivacyKey, rules: Vec<InputPrivacyRule>, ) -> Result<Vec<PrivacyRule>, InvocationError>

Replace your privacy rules for one setting. This overwrites the whole rule set for key, not just one rule in it.

Source

pub async fn get_notify_settings( &self, peer: impl Into<PeerRef>, ) -> Result<PeerNotifySettings, InvocationError>

Get notification settings for a chat - muted, sound, and so on.

Source

pub async fn update_notify_settings( &self, peer: impl Into<PeerRef>, settings: InputPeerNotifySettings, ) -> Result<(), InvocationError>

Change notification settings for a chat.

Source§

impl Client

Source

pub async fn get_reactions( &self, peer: impl Into<PeerRef>, msg_ids: Vec<i32>, ) -> Result<(), InvocationError>

Tell Telegram you’ve seen the reactions on these messages, so it stops marking them as new/unread.

Source

pub async fn delete_reaction( &self, peer: impl Into<PeerRef>, msg_id: i32, participant: impl Into<PeerRef>, ) -> Result<bool, InvocationError>

Report (and request removal of) a specific user’s reaction on a message.

Source

pub async fn iter_reaction_users( &self, peer: impl Into<PeerRef>, msg_id: i32, reaction: Option<Reaction>, limit: i32, offset: Option<String>, ) -> Result<MessageReactionsList, InvocationError>

List who reacted to a message, and with what. Pass reaction to filter to one specific reaction, or None for all of them; offset pages through results.

Source

pub async fn send_paid_reaction( &self, peer: impl Into<PeerRef>, msg_id: i32, count: i32, ) -> Result<(), InvocationError>

Send count Star reactions on a message - the paid reaction type, not a regular emoji one.

Source§

impl Client

Source

pub async fn resolve<P: Into<PeerRef>>( &self, peer: P, ) -> Result<Peer, InvocationError>

Resolve any peer reference to a tl::enums::Peer.

Accepts everything PeerRef accepts:

  • &str / String: "@username", "me", "self", numeric string, t.me/ URL, invite link, E.164 phone
  • i64 / i32: Bot-API encoded numeric ID
  • tl::enums::Peer: returned as-is (zero cost)
  • tl::enums::InputPeer: hash cached, then stripped to Peer

Resolution is cache-first; an RPC is only made on a genuine cache miss.

Join a chat by invite link and return its InputPeer.

Calls messages.importChatInvite, caches all returned entities, and returns the InputPeer of the joined chat. Join a chat or channel via an invite link.

Source

pub async fn check_invite( &self, link: &str, ) -> Result<ChatInvite, InvocationError>

Peek at an invite link without joining.

Returns the title and participant count of the chat the link points to.

Source§

impl Client

Source

pub async fn read_reactions( &self, peer: impl Into<PeerRef>, ) -> Result<(), InvocationError>

Mark all unread reactions in a chat as read.

Source

pub async fn clear_recent_reactions(&self) -> Result<(), InvocationError>

Clear the recent reactions list shown in the reaction picker.

Source

pub async fn get_online_count( &self, peer: impl Into<PeerRef>, ) -> Result<i32, InvocationError>

Get the approximate number of online members in a group or channel.

Source§

impl Client

Source

pub async fn get_sticker_set( &self, stickerset: InputStickerSet, ) -> Result<StickerSet, InvocationError>

Get a sticker set’s contents - title, stickers, and so on.

Source

pub async fn toggle_stickers( &self, stickerset: InputStickerSet, install: bool, ) -> Result<Option<StickerSetInstallResult>, InvocationError>

Install or uninstall a sticker set. install: true installs, install: false uninstalls.

Source

pub async fn get_all_stickers( &self, hash: i64, ) -> Result<Option<Vec<StickerSet>>, InvocationError>

List every sticker set you have installed. Pass the hash from a previous call to get back None cheaply when nothing’s changed, instead of the full list again; 0 always gets the full list.

Source

pub async fn get_custom_emoji_documents( &self, document_ids: Vec<i64>, ) -> Result<Vec<Document>, InvocationError>

Look up custom emoji by their document IDs, to get the actual emoji documents (image/animation data) behind them.

Source§

impl Client

Source

pub async fn get_contacts(&self) -> Result<Vec<User>, InvocationError>

Fetch the full contact list of the current user.

Returns an empty list when the server reports no changes since the last fetch.

Source

pub async fn delete_contacts( &self, user_ids: &[i64], ) -> Result<(), InvocationError>

Remove one or more users from the contact list.

Source

pub async fn block( &self, peer: impl Into<PeerRef>, block: bool, ) -> Result<(), InvocationError>

Block or unblock a user or peer. block: true blocks, block: false unblocks.

Source

pub async fn set_presence(&self, online: bool) -> Result<(), InvocationError>

Set presence status. online: true appears online, online: false appears offline.

Source

pub async fn terminate_session(&self, hash: i64) -> Result<(), InvocationError>

Terminate a specific session by its hash (obtained from Self::get_authorizations).

Source

pub async fn add_contact( &self, user_id: i64, first_name: impl Into<String>, last_name: impl Into<String>, phone: impl Into<String>, add_phone_privacy_exception: bool, ) -> Result<(), InvocationError>

Add a user to your contacts. With add_phone_privacy_exception: true, they’ll be able to see your phone number even if your privacy settings would normally hide it from them.

Source

pub async fn import_contacts( &self, contacts: &[(&str, &str, &str)], ) -> Result<ImportedContacts, InvocationError>

Add several contacts at once, each given as (phone, first_name, last_name).

Source

pub async fn get_blocked_users( &self, offset: i32, limit: i32, ) -> Result<Vec<Peer>, InvocationError>

List the users you’ve blocked. offset/limit page through results.

Source

pub async fn search_contacts( &self, query: impl Into<String>, limit: i32, ) -> Result<Vec<Peer>, InvocationError>

Search your contacts and the global user directory by name or username for query.

Source

pub async fn delete_profile_photos( &self, photo_ids: Vec<(i64, i64, Vec<u8>)>, ) -> Result<Vec<i64>, InvocationError>

Delete profile photos by (id, access_hash, file_reference). Returns the IDs that were actually deleted.

Source

pub fn set_profile(&self, peer: impl Into<PeerRef>) -> SetProfileBuilder

Update user or chat profile fields via a builder.

Call .send().await to apply. Unset fields are left unchanged.

§Example
client.set_profile("me").name("Alice", "").bio("Hello!").send().await.unwrap();
Source

pub async fn get_authorizations( &self, ) -> Result<Vec<Authorization>, InvocationError>

List your active sessions - every device currently logged into this account.

Source

pub async fn get_user_full( &self, user_id: i64, ) -> Result<UserFull, InvocationError>

Get full info for a user - bio, common chats count, blocked status, and other fields the basic user object doesn’t carry.

Source

pub async fn stats( &self, peer: impl Into<PeerRef>, ) -> Result<ChannelStats, InvocationError>

Retrieve channel or supergroup statistics.

Auto-dispatches to stats.getBroadcastStats for channels and stats.getMegagroupStats for supergroups.

Source§

impl Client

Source

pub fn builder() -> ClientBuilder

Return a fluent crate::ClientBuilder for constructing and connecting a client.

§Example
let (client, _shutdown) = Client::builder()
.api_id(12345)
.api_hash("abc123")
.session("my.session")
.catch_up(true)
.connect().await?;
Source

pub async fn connect( config: Config, ) -> Result<(Self, ShutdownToken), InvocationError>

Connect to Telegram and log in (or resume an existing session) using config. This is the first thing you call - it returns your Client plus a ShutdownToken you can use to disconnect cleanly later.

Source

pub async fn save_session(&self) -> Result<(), InvocationError>

Persist the current session to the configured crate::SessionBackend.

Source

pub async fn export_session_string(&self) -> Result<String, InvocationError>

Export the session as a compact string (V2 format).

Encodes dc_id, ip, port, user_id, and auth key. Store in an env var or secret manager and pass back to crate::ClientBuilder::session_string to resume without re-authenticating.

Calls get_me() internally to obtain the user_id.

Source

pub async fn export_native_session_string( &self, ) -> Result<String, InvocationError>

Export the full native session string (DC table, update state, peer cache).

Use this when you need to resume update processing from exactly where you left off (PTS, QTS, seq, peer cache intact). Pass the result back to crate::ClientBuilder::session_string which auto-detects the format.

Source

pub async fn media_dc_addr(&self, dc_id: i32) -> Option<String>

Return the media-only DC address for the given DC id, if known.

Media DCs (media_only = true in DcOption) are preferred for file uploads and downloads because they are not subject to the API rate limits applied to the main DC connection.

Source

pub async fn best_media_dc_addr(&self) -> Option<(i32, String)>

Return the best media DC address for the current home DC (falls back to any known media DC if no home-DC media entry exists).

Source

pub async fn is_authorized(&self) -> Result<bool, InvocationError>

Returns true if the client is already authorized.

Source

pub fn stream_updates(&self) -> UpdateStream

Return an UpdateStream that yields incoming crate::Updates.

The reader task sends all updates to inner.update_tx. This method proxies those updates into a caller-owned channel, applying the overflow strategy from UpdateConfig:

  • DropOldest (default) - a VecDeque ring buffer of queue_capacity slots is maintained in the proxy task. When it is full, the stalest Ephemeral update (typing, online status) is evicted first; if there are none, the oldest Normal update is evicted. The incoming update is always accepted.
  • DropNewest - the incoming update is dropped if the channel is full (original try_send behaviour).

In both cases, internal MTProto state (pts, qts, getDifference) is never touched here. It runs exclusively in the reader task.

Source

pub fn signal_network_restored(&self)

Signal that network connectivity has been restored.

Call this from platform network-change callbacks: Android’s ConnectivityManager, iOS NWPathMonitor, or any other OS hook to make the client attempt an immediate reconnect instead of waiting for the exponential backoff timer to expire.

Safe to call at any time: if the connection is healthy the hint is silently ignored by the reader task; if it is in a backoff loop it wakes up and tries again right away.

Source

pub async fn invoke<R: RemoteCall>( &self, req: &R, ) -> Result<R::Return, InvocationError>

Invoke any TL function directly, handling flood-wait retries.

Source

pub fn disconnect(&self)

Gracefully shut down the client.

Signals the reader task to exit cleanly. Same as cancelling the ShutdownToken returned from Client::connect.

In-flight RPCs will receive a Dropped error. Call save_session() before this if you want to persist the current auth state.

Source

pub async fn channel_kind_of(&self, channel_id: i64) -> Option<ChannelKind>

Look up the cached crate::ChannelKind for a raw channel ID.

Returns None if the channel is not in the peer cache yet. The cache is populated automatically as updates arrive, or you can warm it explicitly with warm_peer_cache_from_dialogs.

Source

pub async fn warm_peer_cache_from_dialogs(&self) -> Result<(), InvocationError>

Fetch the first page of dialogs purely to populate the peer cache with their users/chats. Called automatically on a cache-miss burst (see bulk_peer_hydration); exposed publicly so callers can also warm it up-front instead of waiting for the first miss.

Source

pub async fn resolve_to_input_peer( &self, peer: &Peer, ) -> Result<InputPeer, InvocationError>

Try to resolve a peer to InputPeer, returning an error if the access_hash is unknown (i.e. the peer has not been seen in any prior API call).

Source

pub async fn invoke_on_dc<R: RemoteCall>( &self, dc_id: i32, req: &R, ) -> Result<R::Return, InvocationError>

Invoke a request on a specific DC, using the pool.

If the target DC has no auth key yet, one is acquired via DH and then authorized via auth.exportAuthorization / auth.importAuthorization so the worker DC can serve user-account requests too.

Source§

impl Client

Source

pub async fn upload_file_concurrent( &self, data: Arc<Vec<u8>>, name: &str, mime_type: &str, handle: Option<&TransferHandle>, ) -> Result<UploadedFile, InvocationError>

Upload bytes with parallel worker sessions.

Parallel upload using per-worker connections. Worker count scales with file size. Part size: 32 KB for tiny files, 512 KB otherwise.

  • Files < 10 MB -> upload.saveFilePart (small-file API)
  • Files >= 10 MB -> upload.saveBigFilePart (big-file API)
Source

pub async fn send_file( &self, peer: impl Into<PeerRef>, media: impl Into<InputMedia>, msg: &InputMessage, ) -> Result<IncomingMessage, InvocationError>

Send a file as a document or photo to a chat.

Source

pub async fn send_album( &self, peer: impl Into<PeerRef>, items: Vec<AlbumItem>, ) -> Result<Vec<IncomingMessage>, InvocationError>

Send multiple files as an album.

Each AlbumItem carries its own media, caption, entities (formatting), and optional reply_to message ID.

use ferogram::media::AlbumItem;

let msgs = client.send_album(peer.clone(), vec![
    AlbumItem::new(photo_media).caption_html("<b>First photo</b>"),
    AlbumItem::new(video_media).caption("Second item").reply_to(Some(42)),
]).await?;

// Shorthand: legacy tuple API still works via From impl
client.send_album(peer, vec![
    (photo_media2, "caption".to_string()).into(),
]).await?;
Source§

impl Client

Source

pub async fn get_participants( &self, peer: impl Into<PeerRef>, limit: i32, ) -> Result<Vec<Participant>, InvocationError>

Fetch all participants of a chat, group or channel.

For channels this uses channels.getParticipants; for basic groups it uses messages.getFullChat.

Returns up to limit participants; pass 0 for the default (200 for channels).

Source

pub async fn kick( &self, peer: impl Into<PeerRef>, user_id: i64, ) -> Result<(), InvocationError>

Kick a user from a group chat or channel.

For basic groups, this removes the user immediately. For channels and supergroups, it bans then unbans them (a Telegram kick).

Source

pub async fn ban( &self, channel: impl Into<PeerRef>, user_id: i64, until: Option<i32>, ) -> Result<(), InvocationError>

Ban a user from a channel or supergroup.

until: None is a permanent ban; until: Some(ts) bans until the Unix timestamp.

Source

pub async fn get_profile_photos( &self, peer: impl Into<PeerRef>, limit: i32, ) -> Result<Vec<Photo>, InvocationError>

Iterate profile photos of a user or channel.

Returns a list of photo objects (up to limit).

Source

pub async fn iter_profile_photos( &self, peer: impl Into<PeerRef>, chunk_size: i32, ) -> Result<ProfilePhotoIter, InvocationError>

Stream profile photos of a user lazily, one page at a time.

Returns a ProfilePhotoIter that fetches photos in pages of chunk_size and exposes them one-by-one via .next().await. Set chunk_size to 0 to use the default (100).

Only works for users: channels use messages.search with a photo filter instead.

§Example
let mut iter = client.iter_profile_photos(peer, 0).await?;
while let Some(photo) = iter.next().await? {
println!("{photo:?}");
}
Source

pub async fn search_peer( &self, query: &str, ) -> Result<Vec<Peer>, InvocationError>

Search for a peer (user, group, or channel) by name prefix.

Searches contacts, dialogs, and globally. Returns combined results.

Source§

impl Client

Source

pub async fn restrict( &self, channel: impl Into<PeerRef>, user_id: i64, build: impl FnOnce(BannedRightsBuilder) -> BannedRightsBuilder, ) -> Result<(), InvocationError>

Apply granular ban rights to a user in a channel or supergroup.

Use BannedRightsBuilder to specify which rights to restrict.

Source

pub async fn set_admin( &self, channel: impl Into<PeerRef>, user_id: i64, build: impl FnOnce(AdminRightsBuilder) -> AdminRightsBuilder, ) -> Result<(), InvocationError>

Apply granular admin rights to a user in a channel or supergroup.

Use AdminRightsBuilder to specify which rights to grant.

Source

pub async fn get_participants_filtered( &self, peer: impl Into<PeerRef>, filter: Option<ChannelParticipantsFilter>, limit: i32, ) -> Result<Vec<Participant>, InvocationError>

Fetch participants with an optional filter, paginated.

filter defaults to ChannelParticipantsRecent when None.

Source

pub async fn get_permissions( &self, channel: impl Into<PeerRef>, user_id: i64, ) -> Result<ParticipantPermissions, InvocationError>

Get the effective permissions of a specific user in a channel.

Source§

impl Client

Source

pub async fn quick_connect( session: impl AsRef<Path>, api_id: i32, api_hash: &str, ) -> Result<(Client, ShutdownToken), QuickConnectError>

Connect and authenticate in a single call.

Prompts interactively (stdin) for a phone number or bot token, then drives the full auth flow - login code and 2FA password if required. If the session is already authorized the prompt is skipped entirely.

For advanced options (proxy, custom transport, PFS, catch-up, etc.) use Client::builder() instead.

§Example
use ferogram::Client;

const API_ID: i32 = 0;
const API_HASH: &str = "";

let (client, _) = Client::quick_connect("my.session", API_ID, API_HASH).await?;
Source§

impl Client

Source

pub fn iter_inline_queries(&self) -> InlineQueryIter

Return an iterator that yields every incoming inline query (bot side).

The internal channel is bounded to 256 entries. If the consumer stops calling InlineQueryIter::next and the backlog fills, the feed task exits and the stream ends rather than growing memory without bound.

Source

pub async fn inline_query( &self, bot: Peer, query: &str, ) -> Result<InlineResultIter, InvocationError>

Query a bot’s inline mode and return a paginated InlineResultIter.

Equivalent to typing @bot_username query in a Telegram app.

§Example
let mut iter = client.inline_query(bot, "hello").await?;
while let Some(r) = iter.next().await? {
println!("{}", r.title().unwrap_or("(no title)"));
}
Source§

impl Client

Source

pub async fn typing( &self, peer: impl Into<PeerRef>, ) -> Result<TypingGuard, InvocationError>

Start a scoped typing indicator that auto-cancels when dropped.

A convenience wrapper around TypingGuard::start.

Source

pub async fn typing_in_topic( &self, peer: impl Into<PeerRef>, topic_id: i32, ) -> Result<TypingGuard, InvocationError>

Start a scoped typing indicator in a forum topic thread.

topic_id is the top_msg_id of the forum topic.

Source

pub async fn uploading_document( &self, peer: impl Into<PeerRef>, ) -> Result<TypingGuard, InvocationError>

Start a scoped “uploading document” action that auto-cancels when dropped.

Source

pub async fn recording_video( &self, peer: impl Into<PeerRef>, ) -> Result<TypingGuard, InvocationError>

Start a scoped “recording video” action that auto-cancels when dropped.

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Client

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more