Matrix

Struct Matrix 

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

A container for table-based data entry.

Matrix is a specialized container that displays data in a table format where rows represent items/questions and columns represent possible values.

§Value Format

For single-select (Radio/Dropdown):

{
  "row1_key": "column_value",
  "row2_key": "column_value"
}

For multi-select (Checkbox):

{
  "row1_key": ["value1", "value2"],
  "row2_key": ["value1"]
}

§Example

use paramdef::container::Matrix;

// Satisfaction survey matrix
let satisfaction = Matrix::builder("satisfaction")
    .label("Rate your satisfaction")
    .rows([
        ("price", "Price"),
        ("quality", "Quality"),
        ("support", "Customer Support"),
    ])
    .columns([
        ("1", "Very Poor"),
        ("2", "Poor"),
        ("3", "Fair"),
        ("4", "Good"),
        ("5", "Excellent"),
    ])
    .required()
    .build()
    .unwrap();

// Value: { "price": "4", "quality": "5", "support": "3" }

Implementations§

Source§

impl Matrix

Source

pub fn builder(key: impl Into<Key>) -> MatrixBuilder

Creates a new builder for a Matrix.

Source

pub fn flags(&self) -> Flags

Returns the flags for this matrix.

Source

pub fn rows(&self) -> &[MatrixRow]

Returns all rows.

Source

pub fn row_count(&self) -> usize

Returns the number of rows.

Source

pub fn columns(&self) -> &[MatrixColumn]

Returns all columns.

Source

pub fn column_count(&self) -> usize

Returns the number of columns.

Source

pub fn cell_type(&self) -> MatrixCellType

Returns the cell type.

Source

pub fn all_rows_required(&self) -> bool

Returns true if all rows are required to have a value.

Source

pub fn show_row_numbers(&self) -> bool

Returns true if row numbers should be shown.

Source

pub fn alternate_rows(&self) -> bool

Returns true if alternate row styling is enabled.

Source

pub fn get_row(&self, key: &str) -> Option<&MatrixRow>

Gets a row by key.

Source

pub fn get_column(&self, value: &str) -> Option<&MatrixColumn>

Gets a column by value.

Source

pub fn exclusive_columns(&self) -> impl Iterator<Item = &MatrixColumn>

Returns exclusive columns (columns that deselect others when selected).

Source

pub fn has_exclusive_columns(&self) -> bool

Returns true if this matrix has any exclusive columns.

Source

pub fn row_keys(&self) -> impl Iterator<Item = &Key>

Returns an iterator over row keys.

Source

pub fn column_values(&self) -> impl Iterator<Item = &SmartStr>

Returns an iterator over column values.

Trait Implementations§

Source§

impl Clone for Matrix

Source§

fn clone(&self) -> Matrix

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Container for Matrix

Source§

fn children(&self) -> &[Arc<dyn Node>]

Returns all child nodes.
Source§

impl Debug for Matrix

Source§

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

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

impl Node for Matrix

Source§

fn metadata(&self) -> &Metadata

Returns the node’s metadata.
Source§

fn key(&self) -> &Key

Returns the node’s unique key.
Source§

fn kind(&self) -> NodeKind

Returns the node’s kind (category).
Source§

fn as_any(&self) -> &dyn Any

Returns a reference to the underlying type for downcasting.
Source§

fn as_any_mut(&mut self) -> &mut dyn Any

Returns a mutable reference to the underlying type for downcasting.

Auto Trait Implementations§

§

impl Freeze for Matrix

§

impl RefUnwindSafe for Matrix

§

impl Send for Matrix

§

impl Sync for Matrix

§

impl Unpin for Matrix

§

impl UnwindSafe for Matrix

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> 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.