pub enum PeerRef {
Username(String),
Id(i64),
Peer(Peer),
}Expand description
Flexible reference to a Telegram peer (user, basic group, or channel).
Construct via any of the From impls or by wrapping an already-resolved
tl::enums::Peer. Use peer_ref.resolve(&client).await to obtain the
underlying tl::enums::Peer, performing a network lookup only when the
username is not yet cached.
Variants§
Username(String)
"@username", "username", "me", or "self".
Id(i64)
Numeric ID.
Positive → user.
Negative above −1 000 000 000 000 → basic group (chat_id = -id).
Negative ≤ −1 000 000 000 000 → channel/supergroup
(channel_id = -id - 1_000_000_000_000).
Peer(Peer)
Already-resolved TL peer: forwarded at zero cost.
Implementations§
Source§impl PeerRef
impl PeerRef
Sourcepub async fn resolve(self, client: &Client) -> Result<Peer, InvocationError>
pub async fn resolve(self, client: &Client) -> Result<Peer, InvocationError>
Resolve this reference to a tl::enums::Peer.
Peervariant → returned immediately.Idvariant → decoded from Bot-API encoding, no network call.Usernamevariant → may perform acontacts.resolveUsernameRPC if not already cached.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PeerRef
impl RefUnwindSafe for PeerRef
impl Send for PeerRef
impl Sync for PeerRef
impl Unpin for PeerRef
impl UnsafeUnpin for PeerRef
impl UnwindSafe for PeerRef
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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