Skip to main content

Group

Struct Group 

Source
pub struct Group { /* private fields */ }
Expand description

A named group of nested questionnaire items.

The id is the stable machine identity rendered as the line-terminal tag (<id:command.inputs>); the prompt is human wording and may be edited freely. Every child’s ID must extend the group’s ID with a . segment (command.inputscommand.inputs.name), which keeps submitted occurrence paths derivable from definition IDs.

A plain group (Group::new) renders and is answered exactly once — it structures related questions under one heading. A repeatable group (Group::repeatable) is answered once per submitted occurrence: rendering emits exactly the declared minimum number of blank blocks, and a person adds items by copying a complete block (its heading line and its questions). The number of submitted items is inferred from occurrences of the stable group header, never from display numbers or wording.

Implementations§

Source§

impl Group

Source

pub fn new( id: impl Into<String>, prompt: impl Into<String>, children: impl IntoIterator<Item = impl Into<Item>>, ) -> Self

Create a non-repeatable group with a stable id, human prompt wording, and nested children.

The id, the child-ID prefix rule, and all nested declarations are validated when the group is passed to Questionnaire::new, not here.

Source

pub fn repeatable(self, min: usize) -> Self

Make this group repeatable with at least min occurrences (min >= 1; rendering emits exactly min blank blocks).

Repeat bounds are semantic: they change the fingerprint.

Source

pub fn max_occurrences(self, max: usize) -> Self

Bound a repeatable group to at most max occurrences.

Only meaningful after repeatable; Questionnaire::new rejects a maximum on a non-repeatable group or a maximum below the minimum. Semantic: changes the fingerprint.

Source

pub fn id(&self) -> &str

The stable group ID.

Source

pub fn prompt(&self) -> &str

The human wording (cosmetic).

Source

pub fn children(&self) -> &[Item]

The nested items, in presentation order.

Source

pub fn repeat(&self) -> Option<Repeat>

The repeat bounds, or None for a group answered exactly once.

Trait Implementations§

Source§

impl Clone for Group

Source§

fn clone(&self) -> Group

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Group

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Group

Source§

impl From<Group> for Item

Source§

fn from(group: Group) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Group

Source§

fn eq(&self, other: &Group) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Group

Auto Trait Implementations§

§

impl !RefUnwindSafe for Group

§

impl !UnwindSafe for Group

§

impl Freeze for Group

§

impl Send for Group

§

impl Sync for Group

§

impl Unpin for Group

§

impl UnsafeUnpin for Group

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.