Skip to main content

Button

Struct Button 

Source
pub struct Button { /* private fields */ }
Expand description

A single inline keyboard button.

Implementations§

Source§

impl Button

Source

pub fn callback(text: impl Into<String>, data: impl Into<Vec<u8>>) -> Self

A button that sends a callback data payload when pressed.

Source

pub fn url(text: impl Into<String>, url: impl Into<String>) -> Self

A button that opens a URL in the browser.

Source

pub fn url_auth( text: impl Into<String>, url: impl Into<String>, fwd_text: Option<String>, bot: InputUser, ) -> Self

A button that opens a user-profile or bot link in Telegram.

Source

pub fn switch_inline(text: impl Into<String>, query: impl Into<String>) -> Self

A button that switches to inline mode in the current chat.

Source

pub fn text(label: impl Into<String>) -> Self

A plain text button (for reply keyboards, not inline).

Source

pub fn switch_elsewhere( text: impl Into<String>, query: impl Into<String>, ) -> Self

A button that switches to inline mode in a different (user-chosen) chat.

Source

pub fn webview(text: impl Into<String>, url: impl Into<String>) -> Self

A button that opens a mini-app WebView.

Source

pub fn simple_webview(text: impl Into<String>, url: impl Into<String>) -> Self

A button that opens a simple WebView (no JS bridge).

Source

pub fn request_phone(text: impl Into<String>) -> Self

A button that requests the user’s phone number (reply keyboards only).

Source

pub fn request_geo(text: impl Into<String>) -> Self

A button that requests the user’s location (reply keyboards only).

Source

pub fn request_poll(text: impl Into<String>) -> Self

A button that requests the user to create/share a poll.

Source

pub fn request_quiz(text: impl Into<String>) -> Self

A button that requests the user to create/share a quiz.

Source

pub fn game(text: impl Into<String>) -> Self

A button that launches a game (bots only).

Source

pub fn buy(text: impl Into<String>) -> Self

A buy button for payments (bots only).

Source

pub fn copy_text(text: impl Into<String>, copy_text: impl Into<String>) -> Self

A copy-to-clipboard button.

Source

pub fn into_raw(self) -> KeyboardButton

Consume into the raw TL type.

Trait Implementations§

Source§

impl Clone for Button

Source§

fn clone(&self) -> Button

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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

Source§

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

Source§

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.