pub struct RadioList<T, S> { /* private fields */ }
Expand description
Radio list widget
Implementations§
Source§impl<T, S> RadioList<T, S>where
T: Display,
S: RadioListSettings,
impl<T, S> RadioList<T, S>where
T: Display,
S: RadioListSettings,
Sourcepub fn new(
items: impl IntoIterator<Item = T>,
active_item_i: Option<usize>,
) -> Self
pub fn new( items: impl IntoIterator<Item = T>, active_item_i: Option<usize>, ) -> Self
Examples found in repository?
examples/multiple_widgets.rs (line 147)
146async fn send_complex_widget(bot: Bot, dialogue: Dialogue, message: Message) -> HandlerResult {
147 let shapes = RadioList::new([Shape::Square, Shape::Triangle, Shape::Circle], None);
148
149 let options = CheckboxList::new([Options::A, Options::B, Options::C]);
150
151 let complex_widget = ComplexWidget { shapes, options };
152
153 bot.send_message(message.chat.id, "Choose shape and options:")
154 .reply_markup(complex_widget.inline_keyboard_markup())
155 .await?;
156
157 dialogue
158 .update(State::EditingComplexWidget(complex_widget))
159 .await?;
160
161 Ok(())
162}
More examples
examples/radio_list.rs (lines 107-119)
106async fn send_widget(bot: Bot, dialogue: Dialogue, message: Message) -> HandlerResult {
107 let fruits = FruitsRadioList::new(
108 vec![
109 Fruit {
110 name: "Apple".into(),
111 cost: 42,
112 },
113 Fruit {
114 name: "Pear".into(),
115 cost: 13,
116 },
117 ],
118 None,
119 );
120
121 let widget = Widget { fruits };
122
123 bot.send_message(message.chat.id, "Choose a fruit")
124 .reply_markup(widget.inline_keyboard_markup())
125 .await?;
126
127 dialogue.update(State::EditingWidget(widget)).await?;
128
129 Ok(())
130}
pub fn active_item(&self) -> Option<&T>
pub fn set_active(&mut self, i: usize) -> bool
pub fn items(&self) -> &[T]
Sourcepub fn schema<W>() -> UpdateHandler<W::Err>
pub fn schema<W>() -> UpdateHandler<W::Err>
Examples found in repository?
More examples
pub fn inline_keyboard_markup(&self) -> InlineKeyboardMarkup
Trait Implementations§
Source§impl<'de, T, S> Deserialize<'de> for RadioList<T, S>where
T: Deserialize<'de>,
impl<'de, T, S> Deserialize<'de> for RadioList<T, S>where
T: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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<T, S> From<&RadioList<T, S>> for ReplyMarkupwhere
T: Display,
S: RadioListSettings,
impl<T, S> From<&RadioList<T, S>> for ReplyMarkupwhere
T: Display,
S: RadioListSettings,
Auto Trait Implementations§
impl<T, S> Freeze for RadioList<T, S>where
T: Freeze,
impl<T, S> RefUnwindSafe for RadioList<T, S>where
S: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, S> Send for RadioList<T, S>
impl<T, S> Sync for RadioList<T, S>
impl<T, S> Unpin for RadioList<T, S>
impl<T, S> UnwindSafe for RadioList<T, S>
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<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