pub struct DataView { /* private fields */ }Expand description
A view over a DataTable that can filter, sort, and project columns
without modifying the underlying data
Implementations§
Source§impl DataView
impl DataView
Sourcepub fn with_columns(self, columns: Vec<usize>) -> Self
pub fn with_columns(self, columns: Vec<usize>) -> Self
Create a view with specific columns
Sourcepub fn hide_column(&mut self, display_index: usize) -> bool
pub fn hide_column(&mut self, display_index: usize) -> bool
Hide a column by display index (cannot hide pinned columns)
Sourcepub fn hide_column_by_name(&mut self, column_name: &str) -> bool
pub fn hide_column_by_name(&mut self, column_name: &str) -> bool
Hide a column by name (cannot hide pinned columns)
Sourcepub fn detect_empty_columns(&self) -> Vec<usize>
pub fn detect_empty_columns(&self) -> Vec<usize>
Detect columns that are entirely empty (NULL or empty string) in visible rows
IMPORTANT: This now checks ALL visible rows to ensure accuracy for sparse columns. In real-world trading scenarios (e.g., FIX messages), a column might have only a few non-NULL values among thousands of rows. We cannot afford to miss these due to sampling limitations.
Sourcepub fn hide_empty_columns(&mut self) -> usize
pub fn hide_empty_columns(&mut self) -> usize
Hide all columns that are entirely empty Returns the number of columns hidden
Sourcepub fn unhide_all_columns(&mut self)
pub fn unhide_all_columns(&mut self)
Unhide all columns (restore to the base column projection) This restores to the original column selection, not necessarily all source columns
Sourcepub fn hide_all_columns(&mut self)
pub fn hide_all_columns(&mut self)
Hide all columns (clear all visible columns)
Sourcepub fn has_visible_columns(&self) -> bool
pub fn has_visible_columns(&self) -> bool
Check if any columns are visible
Sourcepub fn move_column_left(&mut self, display_column_index: usize) -> bool
pub fn move_column_left(&mut self, display_column_index: usize) -> bool
Move a column left in the view (respects pinned columns) With wraparound: moving left from first unpinned position moves to last
Sourcepub fn move_column_right(&mut self, display_column_index: usize) -> bool
pub fn move_column_right(&mut self, display_column_index: usize) -> bool
Move a column right in the view (respects pinned columns) With wraparound: moving right from last position moves to first
Sourcepub fn move_column_left_by_name(&mut self, column_name: &str) -> bool
pub fn move_column_left_by_name(&mut self, column_name: &str) -> bool
Move a column by name to the left
Sourcepub fn move_column_right_by_name(&mut self, column_name: &str) -> bool
pub fn move_column_right_by_name(&mut self, column_name: &str) -> bool
Move a column by name to the right
Get the names of hidden columns (columns in source but not visible)
Check if there are any hidden columns
Sourcepub fn pin_column(&mut self, display_index: usize) -> Result<()>
pub fn pin_column(&mut self, display_index: usize) -> Result<()>
Pin a column by display index (move it to the pinned area on the left)
Sourcepub fn pin_column_by_name(&mut self, column_name: &str) -> Result<()>
pub fn pin_column_by_name(&mut self, column_name: &str) -> Result<()>
Pin a column by name
Sourcepub fn unpin_column(&mut self, display_index: usize) -> bool
pub fn unpin_column(&mut self, display_index: usize) -> bool
Unpin a column by display index (move it back to regular visible columns)
Sourcepub fn unpin_column_by_name(&mut self, column_name: &str) -> bool
pub fn unpin_column_by_name(&mut self, column_name: &str) -> bool
Unpin a column by name
Sourcepub fn clear_pinned_columns(&mut self)
pub fn clear_pinned_columns(&mut self)
Clear all pinned columns
Sourcepub fn is_column_pinned(&self, display_index: usize) -> bool
pub fn is_column_pinned(&self, display_index: usize) -> bool
Check if a column at display index is pinned
Sourcepub fn get_pinned_columns(&self) -> &[usize]
pub fn get_pinned_columns(&self) -> &[usize]
Get pinned column indices
Sourcepub fn get_pinned_column_names(&self) -> Vec<String>
pub fn get_pinned_column_names(&self) -> Vec<String>
Get the names of pinned columns
Sourcepub fn get_display_columns(&self) -> Vec<usize>
pub fn get_display_columns(&self) -> Vec<usize>
Get display order of columns (pinned first, then visible)
Sourcepub fn get_display_column_names(&self) -> Vec<String>
pub fn get_display_column_names(&self) -> Vec<String>
Get display column names in order (pinned first, then visible)
Sourcepub fn set_max_pinned_columns(&mut self, max: usize)
pub fn set_max_pinned_columns(&mut self, max: usize)
Set maximum number of pinned columns
Sourcepub fn with_limit(self, limit: usize, offset: usize) -> Self
pub fn with_limit(self, limit: usize, offset: usize) -> Self
Apply limit and offset
Sourcepub fn apply_text_filter(&mut self, pattern: &str, case_sensitive: bool)
pub fn apply_text_filter(&mut self, pattern: &str, case_sensitive: bool)
Apply a text filter to the view (filters visible rows)
Sourcepub fn clear_filter(&mut self)
pub fn clear_filter(&mut self)
Clear all filters (both text and fuzzy) and restore all base rows
Sourcepub fn has_filter(&self) -> bool
pub fn has_filter(&self) -> bool
Check if any filter is active (text or fuzzy)
Sourcepub fn get_filter_pattern(&self) -> Option<&str>
pub fn get_filter_pattern(&self) -> Option<&str>
Get the current text filter pattern
Sourcepub fn get_fuzzy_filter_pattern(&self) -> Option<&str>
pub fn get_fuzzy_filter_pattern(&self) -> Option<&str>
Get the current fuzzy filter pattern
Sourcepub fn apply_fuzzy_filter(&mut self, pattern: &str, case_insensitive: bool)
pub fn apply_fuzzy_filter(&mut self, pattern: &str, case_insensitive: bool)
Apply a fuzzy filter to the view Supports both fuzzy matching and exact matching (when pattern starts with ’)
Sourcepub fn get_fuzzy_filter_indices(&self) -> Vec<usize>
pub fn get_fuzzy_filter_indices(&self) -> Vec<usize>
Get indices of rows that match the fuzzy filter (for compatibility)
Sourcepub fn get_visible_rows(&self) -> Vec<usize>
pub fn get_visible_rows(&self) -> Vec<usize>
Get the visible row indices
Sourcepub fn group_by(
&self,
group_columns: &[String],
) -> Result<BTreeMap<GroupKey, DataView>>
pub fn group_by( &self, group_columns: &[String], ) -> Result<BTreeMap<GroupKey, DataView>>
Group rows by specified columns, returning a map of group keys to DataViews
Each DataView contains only the rows that match the group key
Sourcepub fn sort_by(self, column_index: usize, ascending: bool) -> Result<Self>
pub fn sort_by(self, column_index: usize, ascending: bool) -> Result<Self>
Sort rows by a column (consuming version - returns new Self)
The column_index parameter is the index in the VISIBLE columns
Sourcepub fn apply_sort(&mut self, column_index: usize, ascending: bool) -> Result<()>
pub fn apply_sort(&mut self, column_index: usize, ascending: bool) -> Result<()>
Sort rows by a column (mutable version - modifies in place)
The column_index parameter is the index in the VISIBLE columns
Sourcepub fn apply_multi_sort(&mut self, sort_columns: &[(usize, bool)]) -> Result<()>
pub fn apply_multi_sort(&mut self, sort_columns: &[(usize, bool)]) -> Result<()>
Apply multi-column sorting
Each tuple contains (source_column_index, ascending)
Sourcepub fn toggle_sort(&mut self, column_index: usize) -> Result<()>
pub fn toggle_sort(&mut self, column_index: usize) -> Result<()>
Toggle sort on a column - cycles through Ascending -> Descending -> None
The column_index parameter is the index in the VISIBLE columns
Sourcepub fn get_sort_state(&self) -> &SortState
pub fn get_sort_state(&self) -> &SortState
Get the current sort state
Sourcepub fn get_visible_column_indices(&self) -> Vec<usize>
pub fn get_visible_column_indices(&self) -> Vec<usize>
Get the visible column indices (for debugging)
Returns the internal visible_columns array which maps visual positions to source column indices
Sourcepub fn clear_sort(&mut self)
pub fn clear_sort(&mut self)
Clear the current sort and restore original row order
Sourcepub fn add_virtual_column(&mut self, virtual_column: VirtualColumn)
pub fn add_virtual_column(&mut self, virtual_column: VirtualColumn)
Add a virtual column to the view
Sourcepub fn add_row_numbers(&mut self, position: VirtualColumnPosition)
pub fn add_row_numbers(&mut self, position: VirtualColumnPosition)
Add a row number virtual column
Sourcepub fn remove_virtual_columns(&mut self, name: &str)
pub fn remove_virtual_columns(&mut self, name: &str)
Remove all virtual columns of a specific type by name
Sourcepub fn toggle_row_numbers(&mut self)
pub fn toggle_row_numbers(&mut self)
Toggle row numbers on/off
Sourcepub fn has_row_numbers(&self) -> bool
pub fn has_row_numbers(&self) -> bool
Check if row numbers are currently shown
Sourcepub fn get_all_column_names(&self) -> Vec<String>
pub fn get_all_column_names(&self) -> Vec<String>
Get all column names including virtual columns in display order
Sourcepub fn column_count(&self) -> usize
pub fn column_count(&self) -> usize
Get the number of visible columns (including pinned and virtual)
Sourcepub fn column_names(&self) -> Vec<String>
pub fn column_names(&self) -> Vec<String>
Get column names for visible columns (including virtual columns in correct positions)
Sourcepub fn get_row(&self, index: usize) -> Option<DataRow>
pub fn get_row(&self, index: usize) -> Option<DataRow>
Get a row by index (respecting limit/offset) including virtual columns
Sourcepub fn source_arc(&self) -> Arc<DataTable>
pub fn source_arc(&self) -> Arc<DataTable>
Get the source DataTable as Arc (for memory-efficient sharing)
Sourcepub fn is_column_visible(&self, index: usize) -> bool
pub fn is_column_visible(&self, index: usize) -> bool
Check if a column index is visible (either pinned or regular visible)
Sourcepub fn visible_column_indices(&self) -> &[usize]
pub fn visible_column_indices(&self) -> &[usize]
Get visible column indices (not including pinned)
Sourcepub fn display_column_indices(&self) -> Vec<usize>
pub fn display_column_indices(&self) -> Vec<usize>
Get all display column indices (pinned + visible)
Sourcepub fn visible_row_indices(&self) -> &[usize]
pub fn visible_row_indices(&self) -> &[usize]
Get visible row indices (before limit/offset)
Sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Optimize memory usage by shrinking vectors to fit
Sourcepub fn search_columns(&mut self, pattern: &str)
pub fn search_columns(&mut self, pattern: &str)
Start or update column search with a pattern
Sourcepub fn clear_column_search(&mut self)
pub fn clear_column_search(&mut self)
Clear column search
Sourcepub fn next_column_match(&mut self) -> Option<usize>
pub fn next_column_match(&mut self) -> Option<usize>
Go to next column search match
Sourcepub fn prev_column_match(&mut self) -> Option<usize>
pub fn prev_column_match(&mut self) -> Option<usize>
Go to previous column search match
Sourcepub fn column_search_pattern(&self) -> Option<&str>
pub fn column_search_pattern(&self) -> Option<&str>
Get current column search pattern
Sourcepub fn get_matching_columns(&self) -> &[(usize, String)]
pub fn get_matching_columns(&self) -> &[(usize, String)]
Get matching columns from search
Sourcepub fn current_column_match_index(&self) -> usize
pub fn current_column_match_index(&self) -> usize
Get current column match index
Sourcepub fn get_current_column_match(&self) -> Option<usize>
pub fn get_current_column_match(&self) -> Option<usize>
Get current column match (visible column index)
Sourcepub fn has_column_search(&self) -> bool
pub fn has_column_search(&self) -> bool
Check if column search is active
Sourcepub fn to_json(&self) -> Value
pub fn to_json(&self) -> Value
Export the visible data as JSON Returns an array of objects where each object represents a row
Sourcepub fn to_tsv(&self) -> Result<String>
pub fn to_tsv(&self) -> Result<String>
Export the visible data as TSV (Tab-Separated Values) string
Sourcepub fn get_column_values(&self, column_index: usize) -> Vec<String>
pub fn get_column_values(&self, column_index: usize) -> Vec<String>
Get all values from a specific column (respecting filters and visible rows)
Sourcepub fn get_cell_value(
&self,
row_index: usize,
column_index: usize,
) -> Option<String>
pub fn get_cell_value( &self, row_index: usize, column_index: usize, ) -> Option<String>
Get a single cell value (respecting filters)
Sourcepub fn get_row_values(&self, row_index: usize) -> Option<Vec<String>>
pub fn get_row_values(&self, row_index: usize) -> Option<Vec<String>>
Get a row as string values (respecting filters)
Sourcepub fn get_row_visual_values(&self, row_index: usize) -> Option<Vec<String>>
pub fn get_row_visual_values(&self, row_index: usize) -> Option<Vec<String>>
Get row values in visual column order (only visible columns)
This returns data in the same order as get_display_column_names()
Sourcepub fn get_column_index_mapping(&self) -> Vec<(usize, String, usize)>
pub fn get_column_index_mapping(&self) -> Vec<(usize, String, usize)>
Get column index mapping for debugging Returns a mapping of visible column index -> (column name, datatable index)
Sourcepub fn get_column_debug_info(&self) -> String
pub fn get_column_debug_info(&self) -> String
Get debug information about column visibility and ordering
Trait Implementations§
Source§impl DataProvider for DataView
impl DataProvider for DataView
Source§fn get_row(&self, index: usize) -> Option<Vec<String>>
fn get_row(&self, index: usize) -> Option<Vec<String>>
Source§fn get_column_names(&self) -> Vec<String>
fn get_column_names(&self) -> Vec<String>
Source§fn get_row_count(&self) -> usize
fn get_row_count(&self) -> usize
Source§fn get_column_count(&self) -> usize
fn get_column_count(&self) -> usize
Source§fn get_column_widths(&self) -> Vec<usize>
fn get_column_widths(&self) -> Vec<usize>
Source§fn get_visible_rows(&self, start: usize, count: usize) -> Vec<Vec<String>>
fn get_visible_rows(&self, start: usize, count: usize) -> Vec<Vec<String>>
get_row callsSource§fn get_cell_value(&self, row: usize, col: usize) -> Option<String>
fn get_cell_value(&self, row: usize, col: usize) -> Option<String>
Source§fn get_display_value(&self, row: usize, col: usize) -> String
fn get_display_value(&self, row: usize, col: usize) -> String
Source§fn get_column_type(&self, _column_index: usize) -> DataType
fn get_column_type(&self, _column_index: usize) -> DataType
Source§fn get_column_types(&self) -> Vec<DataType>
fn get_column_types(&self) -> Vec<DataType>
Auto Trait Implementations§
impl Freeze for DataView
impl !RefUnwindSafe for DataView
impl Send for DataView
impl Sync for DataView
impl Unpin for DataView
impl UnsafeUnpin for DataView
impl !UnwindSafe for DataView
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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