#[non_exhaustive]pub struct ChoiceQuestion {
pub instructions: Option<Content>,
pub criteria: IndexMap<String, Option<Content>>,
}Expand description
Picks one option from a set you define.
Options keep the order they were added in. Adding an option with a name that already
exists replaces its description. For options that map to a Rust enum, prefer
EnumChoice.
use typesafe_client::ChoiceQuestion;
let question = ChoiceQuestion::new("Which team should handle this?")
.with_option("billing", "Payments, invoicing, refunds")
.with_option("technical", "Bugs, outages, integrations")
.with_bare_option("sales");
assert_eq!(question.criteria.len(), 3);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.instructions: Option<Content>What the model should decide.
criteria: IndexMap<String, Option<Content>>Option name to description; None is sent as null (the name speaks for itself).
Implementations§
Source§impl ChoiceQuestion
impl ChoiceQuestion
Sourcepub fn new(instructions: impl Into<Content>) -> Self
pub fn new(instructions: impl Into<Content>) -> Self
A Choice asking instructions, with no options yet.
Sourcepub fn with_option(
self,
name: impl Into<String>,
description: impl Into<Content>,
) -> Self
pub fn with_option( self, name: impl Into<String>, description: impl Into<Content>, ) -> Self
Adds an option with a description of when it applies.
Sourcepub fn with_bare_option(self, name: impl Into<String>) -> Self
pub fn with_bare_option(self, name: impl Into<String>) -> Self
Adds an option without a description, for names that are self-explanatory or whose meaning lives in the state (for example line or element ids).
Sourcepub fn with_bare_options<I>(self, names: I) -> Self
pub fn with_bare_options<I>(self, names: I) -> Self
Adds several options without descriptions.
Trait Implementations§
Source§impl Clone for ChoiceQuestion
impl Clone for ChoiceQuestion
Source§fn clone(&self) -> ChoiceQuestion
fn clone(&self) -> ChoiceQuestion
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ChoiceQuestion
impl Debug for ChoiceQuestion
Source§impl Default for ChoiceQuestion
impl Default for ChoiceQuestion
Source§fn default() -> ChoiceQuestion
fn default() -> ChoiceQuestion
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for ChoiceQuestion
impl<'de> Deserialize<'de> for ChoiceQuestion
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 From<ChoiceQuestion> for Question
impl From<ChoiceQuestion> for Question
Source§fn from(question: ChoiceQuestion) -> Self
fn from(question: ChoiceQuestion) -> Self
Converts to this type from the input type.
Source§impl IntoQuestion for ChoiceQuestion
impl IntoQuestion for ChoiceQuestion
Source§type Answer = ChoiceAnswer
type Answer = ChoiceAnswer
How the answer is read; the type parameter of the returned
QuestionKey.Source§fn into_question(self) -> Question
fn into_question(self) -> Question
The question as sent on the wire.
Source§impl PartialEq for ChoiceQuestion
impl PartialEq for ChoiceQuestion
Source§impl Serialize for ChoiceQuestion
impl Serialize for ChoiceQuestion
impl StructuralPartialEq for ChoiceQuestion
Auto Trait Implementations§
impl Freeze for ChoiceQuestion
impl RefUnwindSafe for ChoiceQuestion
impl Send for ChoiceQuestion
impl Sync for ChoiceQuestion
impl Unpin for ChoiceQuestion
impl UnsafeUnpin for ChoiceQuestion
impl UnwindSafe for ChoiceQuestion
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