pub struct GridData {
pub columns: Vec<Column>,
pub rows: Vec<Vec<CellValue>>,
}Expand description
Rectangular grid data: rows.len() rows each of length columns.len().
The library does not silently fix ragged rows; use GridData::new or
GridData::validate to detect and reject them.
Fields§
§columns: Vec<Column>Column metadata. columns.len() is the row width for every row.
rows: Vec<Vec<CellValue>>Row contents. Every row must have exactly columns.len() cells.
Implementations§
Source§impl GridData
impl GridData
Sourcepub fn new(
columns: Vec<Column>,
rows: Vec<Vec<CellValue>>,
) -> Result<Self, GridDataError>
pub fn new( columns: Vec<Column>, rows: Vec<Vec<CellValue>>, ) -> Result<Self, GridDataError>
Construct a new GridData, validating that every row has exactly
columns.len() cells.
§Errors
Returns GridDataError::RaggedRow pointing at the first mis-sized row.
Sourcepub fn validate(&self) -> Result<(), GridDataError>
pub fn validate(&self) -> Result<(), GridDataError>
Validate the rectangular invariant. Cheap; called by GridData::new
and by debug assertions in the paint/copy hot paths.
§Errors
Returns GridDataError::RaggedRow pointing at the first mis-sized row.
Sourcepub fn cell(&self, row: usize, col: usize) -> Option<&CellValue>
pub fn cell(&self, row: usize, col: usize) -> Option<&CellValue>
Safe accessor for cell (row, col). Returns None if either index is
out of bounds.
Sourcepub fn row_count(&self) -> usize
pub fn row_count(&self) -> usize
Number of rows (after sort/filter this reflects the live display_indices
length, not rows.len()).
Sourcepub fn column_count(&self) -> usize
pub fn column_count(&self) -> usize
Number of columns. Always equal to any row’s length if Self::validate
succeeded.
Sourcepub fn column_index(&self, name: &str) -> Option<usize>
pub fn column_index(&self, name: &str) -> Option<usize>
Ordinal index of the first column whose name matches name exactly
(case-sensitive). If duplicate names exist, the first match wins.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GridData
impl RefUnwindSafe for GridData
impl Send for GridData
impl Sync for GridData
impl Unpin for GridData
impl UnsafeUnpin for GridData
impl UnwindSafe for GridData
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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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>
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>
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