Struct grammers_client::types::callback_query::CallbackQuery

source ·
pub struct CallbackQuery { /* private fields */ }
Expand description

Represents a callback query update, which occurs when a user presses one of the bot’s inline callback buttons.

You should always CallbackQuery::answer these queries, even if you have no data to display to the user, because otherwise they will think the bot is non-responsive (the button spinner will timeout).

Implementations§

source§

impl CallbackQuery

source

pub fn sender(&self) -> &Chat

The user who sent this callback query.

source

pub fn chat(&self) -> &Chat

The chat where the callback query occured.

source

pub fn data(&self) -> &[u8]

They binary payload data contained by the inline button which was pressed.

This data cannot be faked by the client, since Telegram will only accept “button presses” on data that actually existed in the buttons of the message, so you do not need to perform any sanity checks.

Trivia: it used to be possible to fake the callback data, but a server-side check was added circa 2018 to prevent malicious clients from doing so.

source

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

Load the Message that contains the pressed inline button.

source

pub fn answer(&self) -> Answer<'_>

Answer the callback query.

Trait Implementations§

source§

impl Clone for CallbackQuery

source§

fn clone(&self) -> CallbackQuery

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for CallbackQuery

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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>,

§

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.