pub struct PeerId(/* private fields */);Expand description
A compact peer identifier.
use std::mem::size_of;
assert_eq!(size_of::<grammers_session::types::PeerId>(), size_of::<i64>());The PeerInfo cached by the session for this PeerId may be retrieved via crate::Session::peer.
The internal representation uses the Bot API Dialog ID format to bit-pack both the peer’s true identifier and type in a single integer.
Internally, arbitrary values outside the valid range of Bot API Dialog ID may be used to represent special peer identifiers.
Implementations§
Source§impl PeerId
impl PeerId
Sourcepub fn self_user() -> Self
pub fn self_user() -> Self
Creates a peer identity for the currently-logged-in user or bot account.
Internally, this will use a special sentinel value outside of any valid Bot API Dialog ID range.
Sourcepub fn channel(id: i64) -> Option<Self>
pub fn channel(id: i64) -> Option<Self>
Creates a peer identity for a broadcast channel, megagroup, gigagroup or monoforum.
Sourcepub fn bot_api_dialog_id(&self) -> i64
pub fn bot_api_dialog_id(&self) -> i64
Returns the identity using the Bot API Dialog ID format.
Will return an arbitrary value if Self::kind is PeerKind::UserSelf.
This value should not be relied on and may change between releases.
Sourcepub fn bare_id(&self) -> i64
pub fn bare_id(&self) -> i64
Unpacked peer identifier. Panics if Self::kind is PeerKind::UserSelf.