pub trait PeerExt {
// Required method
fn bare_id(&self) -> i64;
}Expand description
Convenience extension for tl::enums::Peer: extract the numeric ID
without writing a match every time.
§Example
use ferogram::PeerExt;
use ferogram::OptionPeerExt;
use ferogram::tl;
// Instead of:
// let id = match peer { Peer::User(u) => u.user_id, Peer::Chat(c) => c.chat_id, ... };
// Just write:
let id = peer.bare_id();
// Works great with sender_id() / peer_id() on IncomingMessage:
if let Some(id) = msg.sender_id().bare_id() {
println!("sender: {id}");
}
// Chat ID:
if let Some(id) = msg.peer_id().bare_id() {
println!("chat: {id}");
}Required Methods§
Sourcefn bare_id(&self) -> i64
fn bare_id(&self) -> i64
Returns the raw Telegram ID for any peer variant.
Peer::User→user_idPeer::Chat→chat_id(basic group)Peer::Channel→channel_id(supergroup / broadcast channel)
Note: these are native Telegram IDs, not Bot-API-encoded ones.
A channel with native ID 1234567890 would be -1001234567890 in the
Bot API. Use crate::peer_ref encoding if you need the Bot-API form.