pub struct Prompt {
pub id: String,
pub text: String,
pub buttons: Vec<PromptButton>,
pub allowed: Vec<UserId>,
pub cards: Vec<Card>,
pub select: Option<Select>,
}Expand description
A message with buttons, shown in one conversation. Interactive replies (ADR 0015) add cards and a menu; a prompt with cards may have no text and nothing to answer.
Fields§
§id: StringUnique id, chosen by the runtime.
text: StringThe message, already rendered for the channel.
Up to five buttons.
allowed: Vec<UserId>Who may answer; anyone in the conversation when empty. Others are told it is not theirs.
cards: Vec<Card>Cards shown after the text.
select: Option<Select>A menu shown before the buttons.
Implementations§
Source§impl Prompt
impl Prompt
Sourcepub fn validate(&self) -> Result<(), String>
pub fn validate(&self) -> Result<(), String>
Checks the limits and ids; the message says what is wrong.
The button id.
Sourcepub fn option(&self, id: &str) -> Option<&SelectOption>
pub fn option(&self, id: &str) -> Option<&SelectOption>
The menu option id.
Sourcepub fn answers_with(&self, id: &str) -> bool
pub fn answers_with(&self, id: &str) -> bool
Whether id names something that answers: a button that is not a link, or an option.
Sourcepub fn is_answerable(&self) -> bool
pub fn is_answerable(&self) -> bool
Whether anything in it can be answered.
Sourcepub fn may_answer(&self, user: &UserId) -> bool
pub fn may_answer(&self, user: &UserId) -> bool
Whether user may answer.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Prompt
impl<'de> Deserialize<'de> for Prompt
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
impl Eq for Prompt
impl StructuralPartialEq for Prompt
Auto Trait Implementations§
impl Freeze for Prompt
impl RefUnwindSafe for Prompt
impl Send for Prompt
impl Sync for Prompt
impl Unpin for Prompt
impl UnsafeUnpin for Prompt
impl UnwindSafe for Prompt
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