pub enum Question {
Noul {
instructions: String,
criteria: Option<NoulCriteria>,
},
Choice {
instructions: String,
criteria: BTreeMap<String, String>,
},
Score {
instructions: String,
levels: Vec<String>,
},
}Expand description
One typed question.
Variants§
Noul
Yes/no. criteria optionally describes the two outcomes.
Choice
One of 2..=255 named options; the map value is the option’s description.
Score
Ordered 2..=10 levels, index 0 = lowest.
Implementations§
Source§impl Question
impl Question
Sourcepub fn noul(instructions: impl Into<String>) -> Self
pub fn noul(instructions: impl Into<String>) -> Self
A yes/no question with no outcome descriptions.
Sourcepub fn choice<K: Into<String>, D: Into<String>>(
instructions: impl Into<String>,
options: impl IntoIterator<Item = (K, D)>,
) -> Self
pub fn choice<K: Into<String>, D: Into<String>>( instructions: impl Into<String>, options: impl IntoIterator<Item = (K, D)>, ) -> Self
A choice over (key, description) options.
Sourcepub fn score<L: Into<String>>(
instructions: impl Into<String>,
levels: impl IntoIterator<Item = L>,
) -> Self
pub fn score<L: Into<String>>( instructions: impl Into<String>, levels: impl IntoIterator<Item = L>, ) -> Self
A score over ordered levels, lowest first.
pub fn instructions(&self) -> &str
Sourcepub fn validate(&self, id: &str) -> Result<(), DecideError>
pub fn validate(&self, id: &str) -> Result<(), DecideError>
DEC-E006 unless the question is askable: non-empty instructions,
2..=255 non-empty option keys, 2..=10 levels.
Sourcepub fn to_wire(&self) -> Value
pub fn to_wire(&self) -> Value
The wire form: criteria is an object for noul/choice and an ARRAY of
levels for score.
Sourcepub fn from_wire(id: &str, v: &Value) -> Result<Self, DecideError>
pub fn from_wire(id: &str, v: &Value) -> Result<Self, DecideError>
Parse one wire question. Shape faults are DEC-E006; the counts are
checked too (this calls Question::validate).
Trait Implementations§
impl Eq for Question
impl StructuralPartialEq for Question
Auto Trait Implementations§
impl Freeze for Question
impl RefUnwindSafe for Question
impl Send for Question
impl Sync for Question
impl Unpin for Question
impl UnsafeUnpin for Question
impl UnwindSafe for Question
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