pub struct QuestionnaireState<A> { /* private fields */ }Expand description
A small, presentation-independent questionnaire controller.
A is the application’s answer type, which may be an enum for different
kinds of question. Editors, prompts, validation, and persistence belong to the
application. There is no schema interpreter or form field registry. Retain
this value in the application’s view, and notify that view after navigation.
Answer values survive Back, review, completion, and editing a previous step.
Implementations§
Source§impl<A> QuestionnaireState<A>
impl<A> QuestionnaireState<A>
Sourcepub fn new(question_count: usize) -> Self
pub fn new(question_count: usize) -> Self
Creates a fixed linear flow. An empty flow starts at Review.
pub fn stage(&self) -> QuestionnaireStage
pub fn question_count(&self) -> usize
pub fn answer(&self, index: usize) -> Option<&A>
pub fn answers(&self) -> &[Option<A>]
pub fn error(&self) -> Option<&SharedString>
Sourcepub fn submit_answer(
&mut self,
answer: A,
validation: Result<(), SharedString>,
) -> bool
pub fn submit_answer( &mut self, answer: A, validation: Result<(), SharedString>, ) -> bool
Retains the submitted answer, including when validation rejects it. Advances only on the application’s successful validation result. An error stays on its question; submit again to replace it.
pub fn can_go_back(&self) -> bool
Auto Trait Implementations§
impl<A> Forget for QuestionnaireState<A>
impl<A> Freeze for QuestionnaireState<A>
impl<A> Move for QuestionnaireState<A>
impl<A> RefUnwindSafe for QuestionnaireState<A>
impl<A> Send for QuestionnaireState<A>
impl<A> Sync for QuestionnaireState<A>
impl<A> Unpin for QuestionnaireState<A>
impl<A> UnsafeUnpin for QuestionnaireState<A>where
*const u8 is !null: UnsafeUnpin,
PhantomData<Option<A>>: UnsafeUnpin,
&'static str: UnsafeUnpin,
*const ArcInner<str> is !null: UnsafeUnpin,
PhantomData<ArcInner<str>>: UnsafeUnpin,
impl<A> UnwindSafe for QuestionnaireState<A>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
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