Types Reference
ferogram wraps the raw TL layer’s tl::enums::User and tl::enums::Chat
variants in typed structs so you never need to pattern-match bare enums.
| Wrapper | Underlying TL type |
|---|---|
User | tl::enums::User (variant User) |
Group | tl::types::Chat |
Channel | tl::types::Channel |
Chat | Unified enum: Chat::Group or Chat::Channel |
All four types are available without any feature flags.
User
User wraps a non-empty tl::enums::User::User variant.
Construction
None for tl::enums::User::Empty, Some(User) otherwise.
The raw field is public if you need direct TL access.
Identity
None for users not in your contact list or not recently seen.@ prefix.@.Flags
true if this is a bot account.true if the account has a blue verification badge.true if the user has Telegram Premium.true if this is the currently logged-in account.true if the account has been deleted.true if Telegram has flagged this account as a scam.true if the account is spam-restricted.true if this user is in the logged-in user's contact list.true if the logged-in user is also in this user's contact list.true if this account belongs to Telegram support staff.Online & Media
Online, Offline, Recently, LastWeek, LastMonth, Empty).client.iter_profile_photos() to download the actual image.Bot-specific
true if the bot can be used inline without requiring a location share.true if the bot can be added to groups/channels.Peer Conversion
PeerUser for use in API calls.InputPeer. Returns InputPeerUser { user_id, access_hash } when
an access hash is available, or InputPeerPeerSelf for the logged-in account.
User also implements Display as "Full Name (@username)" or "Full Name [id]".
Group
Group wraps a basic group (tl::types::Chat). Basic groups have ≤ 200 members;
larger groups are supergroups (use Channel with megagroup() == true).
Construction
None if the raw value is Empty, Forbidden, Channel, or ChannelForbidden.
The raw field (tl::types::Chat) is public for direct TL access.
Accessors
true if the logged-in user is the creator of this group.InputChannel of the new supergroup.PeerChat.InputPeerChat.Group implements Display as "Title [group id]".
Channel
Channel wraps both broadcast channels and supergroups
(tl::types::Channel). Use kind() or megagroup() / broadcast() to
distinguish them.
Construction
None for non-channel variants. The raw field (tl::types::Channel) is public.
Identity
@, if set.@.None for private channels.Kind
| Variant | Description |
|---|---|
ChannelKind::Broadcast | Broadcast channel (posts only) |
ChannelKind::Megagroup | Supergroup (all members can post) |
ChannelKind::Gigagroup | Large broadcast group (gigagroup) |
true for supergroups.true for broadcast channels.Flags
true if the channel has a verification badge.true if the channel is unavailable in certain regions.true if post author signatures are shown in the channel.Rights & Media
Peer Conversion
PeerChannel.InputPeerChannel { channel_id, access_hash }. Returns InputPeerEmpty if the access hash is absent.InputChannel for channel-specific RPCs (e.g. channels.GetParticipants). Returns InputChannelEmpty if the access hash is absent.Channel implements Display as "Title (@username)" or "Title [channel id]".
Chat (unified enum)
Chat is a convenience enum that holds either a Group or a Channel.
Most client methods return peers as Chat when the type is not known in advance.
#![allow(unused)]
fn main() {
match chat {
Chat::Group(g) => println!("Basic group: {}", g.title()),
Chat::Channel(c) => println!("Channel/supergroup: {}", c.title()),
}
}
Construction
None for Empty, Forbidden, and ChannelForbidden variants.Common Accessors
Peer variant.InputPeer variant.Quick Reference
#![allow(unused)]
fn main() {
use ferogram::{User, Group, Channel, Chat};
// User
if let Some(user) = User::from_raw(raw_user) {
println!("{} id={}", user.full_name(), user.id());
if user.bot() { println!("It's a bot"); }
let peer = user.as_input_peer(); // for API calls
}
// Group
if let Some(group) = Group::from_raw(raw_chat) {
println!("{} ({} members)", group.title(), group.participants_count());
}
// Channel / Supergroup
if let Some(ch) = Channel::from_raw(raw_chat) {
match ch.kind() {
ferogram::ChannelKind::Broadcast => println!("Channel"),
ferogram::ChannelKind::Megagroup => println!("Supergroup"),
ferogram::ChannelKind::Gigagroup => println!("Gigagroup"),
}
}
// Unified
if let Some(chat) = Chat::from_raw(raw_chat) {
println!("id={} title={}", chat.id(), chat.title());
}
}