pub struct InlineKeyboardButton {
pub text: String,
pub kind: InlineKeyboardButtonKind,
}
Expand description
This object represents one button of an inline keyboard.
Fields§
§text: String
Label text on the button.
kind: InlineKeyboardButtonKind
Implementations§
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?
examples/buttons.rs (line 51)
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
examples/purchase.rs (line 114)
110async fn receive_full_name(bot: Bot, dialogue: MyDialogue, msg: Message) -> HandlerResult {
111 match msg.text().map(ToOwned::to_owned) {
112 Some(full_name) => {
113 let products = ["Apple", "Banana", "Orange", "Potato"]
114 .map(|product| InlineKeyboardButton::callback(product, product));
115
116 bot.send_message(msg.chat.id, "Select a product:")
117 .reply_markup(InlineKeyboardMarkup::new([products]))
118 .await?;
119 dialogue.update(State::ReceiveProductChoice { full_name }).await?;
120 }
121 None => {
122 bot.send_message(msg.chat.id, "Please, send me your full name.").await?;
123 }
124 }
125
126 Ok(())
127}
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.
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
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
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>,
Deserialize this value from the given Serde deserializer. Read more
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,
Serialize this value into the given Serde serializer. Read more
impl Eq for InlineKeyboardButton
impl StructuralPartialEq for InlineKeyboardButton
Auto Trait Implementations§
impl Freeze for InlineKeyboardButton
impl RefUnwindSafe for InlineKeyboardButton
impl Send for InlineKeyboardButton
impl Sync for InlineKeyboardButton
impl Unpin for InlineKeyboardButton
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
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<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
Compare self to
key
and return true
if they are equal.Source§impl<T> Erasable for T
impl<T> Erasable for T
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