pub struct InlineKeyboardButton {
pub text: String,
pub icon_custom_emoji_id: Option<CustomEmojiId>,
pub style: Option<ButtonStyle>,
pub kind: InlineKeyboardButtonKind,
}Expand description
This object represents one button of an inline keyboard.
Fields§
§text: StringLabel text on the button.
icon_custom_emoji_id: Option<CustomEmojiId>Unique identifier of the custom emoji shown before the text of the button. Can only be used by bots that purchased additional usernames on Fragment or in the messages directly sent by the bot to private, group and supergroup chats if the owner of the bot has a Telegram Premium subscription.
style: Option<ButtonStyle>Style of the button. If omitted, then an app-specific style is used.
kind: InlineKeyboardButtonKindImplementations§
Source§impl InlineKeyboardButton
impl InlineKeyboardButton
Sourcepub fn new<S>(text: S, kind: InlineKeyboardButtonKind) -> InlineKeyboardButton
pub fn new<S>(text: S, kind: InlineKeyboardButtonKind) -> InlineKeyboardButton
Creates a new InlineKeyboardButton.
Sourcepub fn url<T>(text: T, url: Url) -> InlineKeyboardButton
pub fn url<T>(text: T, url: Url) -> InlineKeyboardButton
Constructor for InlineKeyboardButton with Url kind.
Sourcepub fn login<T>(text: T, url: LoginUrl) -> InlineKeyboardButton
pub fn login<T>(text: T, url: LoginUrl) -> InlineKeyboardButton
Constructor for InlineKeyboardButton with LoginUrl kind.
Sourcepub fn callback<T, C>(text: T, callback_data: C) -> InlineKeyboardButton
pub fn callback<T, C>(text: T, callback_data: C) -> InlineKeyboardButton
Constructor for InlineKeyboardButton with CallbackData kind.
Examples found in repository?
40fn make_keyboard() -> InlineKeyboardMarkup {
41 let mut keyboard: Vec<Vec<InlineKeyboardButton>> = vec![];
42
43 let debian_versions = [
44 "Buzz", "Rex", "Bo", "Hamm", "Slink", "Potato", "Woody", "Sarge", "Etch", "Lenny",
45 "Squeeze", "Wheezy", "Jessie", "Stretch", "Buster", "Bullseye",
46 ];
47
48 for versions in debian_versions.chunks(3) {
49 let row = versions
50 .iter()
51 .map(|&version| InlineKeyboardButton::callback(version.to_owned(), version.to_owned()))
52 .collect();
53
54 keyboard.push(row);
55 }
56
57 InlineKeyboardMarkup::new(keyboard)
58}More examples
111async fn receive_full_name(bot: Bot, dialogue: MyDialogue, msg: Message) -> HandlerResult {
112 match msg.text().map(ToOwned::to_owned) {
113 Some(full_name) => {
114 let products = ["Apple", "Banana", "Orange", "Potato"]
115 .map(|product| InlineKeyboardButton::callback(product, product));
116
117 bot.send_message("Select a product:")
118 .chat_id(msg.chat.id)
119 .reply_markup(InlineKeyboardMarkup::new([products]))
120 .await?;
121 dialogue.update(State::ReceiveProductChoice { full_name }).await?;
122 }
123 None => {
124 bot.send_message("Please, send me your full name.").chat_id(msg.chat.id).await?;
125 }
126 }
127
128 Ok(())
129}Sourcepub fn web_app<T>(text: T, info: WebAppInfo) -> InlineKeyboardButton
pub fn web_app<T>(text: T, info: WebAppInfo) -> InlineKeyboardButton
Constructor for InlineKeyboardButton with WebApp kind.
Sourcepub fn switch_inline_query<T, Q>(
text: T,
switch_inline_query: Q,
) -> InlineKeyboardButton
pub fn switch_inline_query<T, Q>( text: T, switch_inline_query: Q, ) -> InlineKeyboardButton
Constructor for InlineKeyboardButton with SwitchInlineQuery kind.
Sourcepub fn switch_inline_query_current_chat<T, Q>(
text: T,
switch_inline_query_current_chat: Q,
) -> InlineKeyboardButton
pub fn switch_inline_query_current_chat<T, Q>( text: T, switch_inline_query_current_chat: Q, ) -> InlineKeyboardButton
Constructor for InlineKeyboardButton with
SwitchInlineQueryCurrentChat kind.
Constructor for InlineKeyboardButton with
CopyText kind.
Sourcepub fn callback_game<T>(text: T, game: CallbackGame) -> InlineKeyboardButton
pub fn callback_game<T>(text: T, game: CallbackGame) -> InlineKeyboardButton
Constructor for InlineKeyboardButton with CallbackGame kind.
Trait Implementations§
Source§impl Clone for InlineKeyboardButton
impl Clone for InlineKeyboardButton
Source§fn clone(&self) -> InlineKeyboardButton
fn clone(&self) -> InlineKeyboardButton
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for InlineKeyboardButton
impl Debug for InlineKeyboardButton
Source§impl<'de> Deserialize<'de> for InlineKeyboardButton
impl<'de> Deserialize<'de> for InlineKeyboardButton
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<InlineKeyboardButton, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<InlineKeyboardButton, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Eq for InlineKeyboardButton
Source§impl Hash for InlineKeyboardButton
impl Hash for InlineKeyboardButton
Source§impl PartialEq for InlineKeyboardButton
impl PartialEq for InlineKeyboardButton
Source§impl Serialize for InlineKeyboardButton
impl Serialize for InlineKeyboardButton
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for InlineKeyboardButton
Auto Trait Implementations§
impl Forget for InlineKeyboardButton
impl Freeze for InlineKeyboardButtonwhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<Value>: Freeze,
*const LeafNode<String, Value> is !null: Freeze,
PhantomData<(Owned, LeafOrInternal)>: Freeze,
PhantomData<Box<(String, Value)>>: Freeze,
impl Move for InlineKeyboardButton
impl RefUnwindSafe for InlineKeyboardButton
impl Send for InlineKeyboardButton
impl Sync for InlineKeyboardButton
impl Unpin for InlineKeyboardButton
impl UnsafeUnpin for InlineKeyboardButtonwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<Value>: UnsafeUnpin,
*const LeafNode<String, Value> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(String, Value)>>: UnsafeUnpin,
impl UnwindSafe for InlineKeyboardButton
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Erasable for T
impl<T> Erasable for T
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> ⓘ
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> ⓘ
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