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
impl Matrix
Sourcepub fn builder(key: impl Into<Key>) -> MatrixBuilder
pub fn builder(key: impl Into<Key>) -> MatrixBuilder
Creates a new builder for a Matrix.
Sourcepub fn columns(&self) -> &[MatrixColumn]
pub fn columns(&self) -> &[MatrixColumn]
Returns all columns.
Sourcepub fn column_count(&self) -> usize
pub fn column_count(&self) -> usize
Returns the number of columns.
Sourcepub fn cell_type(&self) -> MatrixCellType
pub fn cell_type(&self) -> MatrixCellType
Returns the cell type.
Sourcepub fn all_rows_required(&self) -> bool
pub fn all_rows_required(&self) -> bool
Returns true if all rows are required to have a value.
Sourcepub fn show_row_numbers(&self) -> bool
pub fn show_row_numbers(&self) -> bool
Returns true if row numbers should be shown.
Sourcepub fn alternate_rows(&self) -> bool
pub fn alternate_rows(&self) -> bool
Returns true if alternate row styling is enabled.
Sourcepub fn get_column(&self, value: &str) -> Option<&MatrixColumn>
pub fn get_column(&self, value: &str) -> Option<&MatrixColumn>
Gets a column by value.
Sourcepub fn exclusive_columns(&self) -> impl Iterator<Item = &MatrixColumn>
pub fn exclusive_columns(&self) -> impl Iterator<Item = &MatrixColumn>
Returns exclusive columns (columns that deselect others when selected).
Sourcepub fn has_exclusive_columns(&self) -> bool
pub fn has_exclusive_columns(&self) -> bool
Returns true if this matrix has any exclusive columns.
Sourcepub fn column_values(&self) -> impl Iterator<Item = &SmartStr>
pub fn column_values(&self) -> impl Iterator<Item = &SmartStr>
Returns an iterator over column values.
Trait Implementations§
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> 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