Struct tgbot::types::Quiz

source ·
pub struct Quiz {
    pub correct_option_id: Integer,
    pub id: String,
    pub is_anonymous: bool,
    pub is_closed: bool,
    pub options: Vec<PollOption>,
    pub question: String,
    pub total_voter_count: Integer,
    pub close_date: Option<Integer>,
    pub explanation: Option<Text>,
    pub open_period: Option<Integer>,
}
Expand description

Represents a quiz.

Fields§

§correct_option_id: Integer

0-based identifier of the correct answer option.

Available only for a closed quiz, or was sent (not forwarded) by the bot or to the private chat with the bot.

§id: String

Unique identifier of the quiz.

§is_anonymous: bool

Indicates whether the quiz is anonymous.

§is_closed: bool

Indicates whether the quiz is closed.

§options: Vec<PollOption>

List of options.

§question: String

Question; 1-255 characters.

§total_voter_count: Integer

Total number of users that answered to the quiz.

§close_date: Option<Integer>

Point in time (Unix timestamp) when the quiz will be automatically closed.

§explanation: Option<Text>

Text that is shown when a user chooses an incorrect answer or taps on the lamp icon; 0-200 characters.

§open_period: Option<Integer>

Amount of time in seconds the quiz will be active after creation.

Implementations§

source§

impl Quiz

source

pub fn new<A, B>(id: A, question: B) -> Self
where A: Into<String>, B: Into<String>,

Creates a new Quiz.

§Arguments
  • id - Unique identifier.
  • question - Question; 1-255 characters.
source

pub fn with_close_date(self, value: Integer) -> Self

Sets a new close date.

§Arguments
  • value - Point in time (Unix timestamp) when the quiz will be automatically closed.
source

pub fn with_correct_option_id(self, value: Integer) -> Self

Sets a new correct option ID.

§Arguments
  • value - 0-based identifier of the correct answer option.
source

pub fn with_explanation<T>(self, value: T) -> Self
where T: Into<Text>,

Sets a new explanation.

§Arguments
  • value - Text that is shown when a user chooses an incorrect answer or taps on the lamp icon; 0-200 characters.
source

pub fn with_is_anonymous(self, value: bool) -> Self

Sets a new value for the is_anonymous flag.

§Arguments
  • value - Indicates whether the quiz is anonymous.
source

pub fn with_is_closed(self, value: bool) -> Self

Sets a new value for the is_closed flag.

§Arguments
  • value - Indicates whether the quiz is closed.
source

pub fn with_open_period(self, value: Integer) -> Self

Sets a new open period.

§Arguments
  • value - Amount of time in seconds the quiz will be active after creation.
source

pub fn with_options<T>(self, value: T) -> Self
where T: IntoIterator<Item = PollOption>,

Sets a new list of options.

§Arguments
  • value - The list of options.
source

pub fn with_total_voter_count(self, value: Integer) -> Self

Sets a new correct total voter count.

§Arguments
  • value - Total number of users that answered to the quiz.

Trait Implementations§

source§

impl Clone for Quiz

source§

fn clone(&self) -> Quiz

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Quiz

source§

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

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

impl<'de> Deserialize<'de> for Quiz

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 From<Quiz> for Poll

source§

fn from(original: Quiz) -> Poll

Converts to this type from the input type.
source§

impl PartialEq for Quiz

source§

fn eq(&self, other: &Quiz) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Quiz

source§

fn partial_cmp(&self, other: &Quiz) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Serialize for Quiz

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

impl StructuralPartialEq for Quiz

Auto Trait Implementations§

§

impl Freeze for Quiz

§

impl RefUnwindSafe for Quiz

§

impl Send for Quiz

§

impl Sync for Quiz

§

impl Unpin for Quiz

§

impl UnwindSafe for Quiz

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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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,

§

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

§

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

§

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> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

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