Skip to main content

Poll

Struct Poll 

Source
pub struct Poll {
Show 21 fields pub id: String, pub question: String, pub question_entities: Option<Vec<MessageEntity>>, pub options: Vec<PollOption>, pub total_voter_count: u32, pub is_closed: bool, pub is_anonymous: bool, pub kind: PollType, pub allows_multiple_answers: bool, pub allows_revoting: bool, pub correct_option_ids: Option<Vec<u8>>, pub explanation: Option<String>, pub explanation_entities: Option<Vec<MessageEntity>>, pub open_period: Option<u32>, pub close_date: Option<i64>, pub description: Option<String>, pub description_entities: Option<Vec<MessageEntity>>, pub media: Option<PollMedia>, pub explanation_media: Option<PollMedia>, pub members_only: Option<bool>, pub country_codes: Option<Vec<String>>,
}
Expand description

A native Telegram poll or quiz.

Polls are either regular (users vote freely) or quiz (one or more correct answers). Returned inside Message when a poll is sent or forwarded.

Fields§

§id: String

Unique poll identifier.

§question: String

Poll question (1–300 characters).

§question_entities: Option<Vec<MessageEntity>>

Special entities in the question.

§options: Vec<PollOption>

List of answer options.

§total_voter_count: u32

Total number of users who voted.

§is_closed: bool

true if the poll is closed.

§is_anonymous: bool

true if the poll is anonymous.

§kind: PollType

Poll type.

§allows_multiple_answers: bool

true if the poll allows multiple answers.

§allows_revoting: bool

true if voters can change their chosen answer options.

§correct_option_ids: Option<Vec<u8>>

Zero-based indices of the correct answers (quiz polls only).

Bot API 9.6 changed this from a single u8 to an array to support quizzes with multiple correct answers.

§explanation: Option<String>

Explanation shown after a quiz is answered.

§explanation_entities: Option<Vec<MessageEntity>>

Special entities in the explanation.

§open_period: Option<u32>

Duration in seconds the poll stays active after creation.

§close_date: Option<i64>

Unix timestamp when the poll closes automatically.

§description: Option<String>

Description of the poll; present only inside Message objects.

§description_entities: Option<Vec<MessageEntity>>

Special entities in the description.

§media: Option<PollMedia>

Media added to the poll description; present only inside Message objects.

§explanation_media: Option<PollMedia>

Media added to the quiz explanation.

§members_only: Option<bool>

true if voting is limited to users who have been members of the chat for more than 24 hours.

§country_codes: Option<Vec<String>>

Two-letter ISO 3166-1 alpha-2 country codes indicating the countries from which users can vote. If absent, users from any country can participate.

Trait Implementations§

Source§

impl Clone for Poll

Source§

fn clone(&self) -> Poll

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Poll

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Poll

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Poll

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Poll

§

impl RefUnwindSafe for Poll

§

impl Send for Poll

§

impl Sync for Poll

§

impl Unpin for Poll

§

impl UnsafeUnpin for Poll

§

impl UnwindSafe for Poll

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,