pub struct InlineKeyboardMarkup {
pub inline_keyboard: Vec<Vec<InlineKeyboardButton>>,
}Expand description
This object represents an inline keyboard that appears right next to the message it belongs to.
Note: This will only work in Telegram versions released after 9 April, 2016. Older clients will display unsupported message.
Fields§
§inline_keyboard: Vec<Vec<InlineKeyboardButton>>Array of button rows, each represented by an array of
InlineKeyboardButton objects.
Implementations§
Source§impl InlineKeyboardMarkup
Build InlineKeyboardMarkup.
impl InlineKeyboardMarkup
Build InlineKeyboardMarkup.
§Examples
use teloxide_core_ng::types::{InlineKeyboardButton, InlineKeyboardMarkup};
let url = url::Url::parse("https://example.com").unwrap();
let url_button = InlineKeyboardButton::url("text".to_string(), url);
let keyboard = InlineKeyboardMarkup::default().append_row(vec![url_button]);Sourcepub fn new<I>(inline_keyboard: I) -> InlineKeyboardMarkup
pub fn new<I>(inline_keyboard: I) -> InlineKeyboardMarkup
Examples found in repository?
examples/buttons.rs (line 57)
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 117)
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}pub fn inline_keyboard<I>(self, val: I) -> InlineKeyboardMarkup
pub fn append_row<R>(self, buttons: R) -> InlineKeyboardMarkupwhere
R: IntoIterator<Item = InlineKeyboardButton>,
pub fn append_to_row( self, index: usize, button: InlineKeyboardButton, ) -> InlineKeyboardMarkup
Trait Implementations§
Source§impl Clone for InlineKeyboardMarkup
impl Clone for InlineKeyboardMarkup
Source§fn clone(&self) -> InlineKeyboardMarkup
fn clone(&self) -> InlineKeyboardMarkup
Returns a duplicate 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 InlineKeyboardMarkup
impl Debug for InlineKeyboardMarkup
Source§impl Default for InlineKeyboardMarkup
impl Default for InlineKeyboardMarkup
Source§fn default() -> InlineKeyboardMarkup
fn default() -> InlineKeyboardMarkup
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for InlineKeyboardMarkup
impl<'de> Deserialize<'de> for InlineKeyboardMarkup
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<InlineKeyboardMarkup, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<InlineKeyboardMarkup, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<InlineKeyboardMarkup> for ReplyMarkup
impl From<InlineKeyboardMarkup> for ReplyMarkup
Source§fn from(value: InlineKeyboardMarkup) -> ReplyMarkup
fn from(value: InlineKeyboardMarkup) -> ReplyMarkup
Converts to this type from the input type.
Source§impl Hash for InlineKeyboardMarkup
impl Hash for InlineKeyboardMarkup
Source§impl PartialEq for InlineKeyboardMarkup
impl PartialEq for InlineKeyboardMarkup
Source§impl Serialize for InlineKeyboardMarkup
impl Serialize for InlineKeyboardMarkup
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 InlineKeyboardMarkup
impl StructuralPartialEq for InlineKeyboardMarkup
Auto Trait Implementations§
impl Freeze for InlineKeyboardMarkup
impl RefUnwindSafe for InlineKeyboardMarkup
impl Send for InlineKeyboardMarkup
impl Sync for InlineKeyboardMarkup
impl Unpin for InlineKeyboardMarkup
impl UnwindSafe for InlineKeyboardMarkup
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§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