pub struct Questions<'a> { /* private fields */ }Expand description
The questions of one call, keyed by the names their answers come back under.
The order questions are added in is the order they are sent in. Adding a name that is already there replaces that question and keeps its position, as the upstream SDK’s dictionary does.
Nothing is checked until prepare, which validates and
serializes the whole set once.
Implementations§
Source§impl<'a> Questions<'a>
impl<'a> Questions<'a>
Sourcepub fn question(
self,
name: impl Into<Cow<'a, str>>,
question: impl Into<Question<'a>>,
) -> Self
pub fn question( self, name: impl Into<Cow<'a, str>>, question: impl Into<Question<'a>>, ) -> Self
Adds a question of any kind under name.
Sourcepub fn noul(self, name: impl Into<Cow<'a, str>>, question: Noul<'a>) -> Self
pub fn noul(self, name: impl Into<Cow<'a, str>>, question: Noul<'a>) -> Self
Adds a yes/no question under name.
Sourcepub fn choice(self, name: impl Into<Cow<'a, str>>, question: Choice<'a>) -> Self
pub fn choice(self, name: impl Into<Cow<'a, str>>, question: Choice<'a>) -> Self
Adds a choice question under name.
Sourcepub fn score(self, name: impl Into<Cow<'a, str>>, question: Score<'a>) -> Self
pub fn score(self, name: impl Into<Cow<'a, str>>, question: Score<'a>) -> Self
Adds a score question under name.
Sourcepub fn raw(
self,
name: impl Into<Cow<'a, str>>,
question: RawQuestion<'a>,
) -> Self
pub fn raw( self, name: impl Into<Cow<'a, str>>, question: RawQuestion<'a>, ) -> Self
Adds a raw question under name.
Sourcepub fn prepare(self) -> Result<PreparedQuestions, Error>
pub fn prepare(self) -> Result<PreparedQuestions, Error>
Validates the set and serializes it into the bytes every call will send.
§Errors
Returns an ErrorKind::InvalidRequest
error, with the upstream SDK’s message, when the set is empty, when a
score has no levels, when a raw question’s type is not a nonempty
string, when a raw choice or score has no criteria, when a raw
score’s criteria is empty, or when a raw question’s field could not
be encoded. The first failing question, in order, is the one reported.
Trait Implementations§
impl<'a> Eq for Questions<'a>
impl<'a> StructuralPartialEq for Questions<'a>
Auto Trait Implementations§
impl<'a> Freeze for Questions<'a>
impl<'a> RefUnwindSafe for Questions<'a>
impl<'a> Send for Questions<'a>
impl<'a> Sync for Questions<'a>
impl<'a> Unpin for Questions<'a>
impl<'a> UnsafeUnpin for Questions<'a>
impl<'a> UnwindSafe for Questions<'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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.