DataView

Struct DataView 

Source
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

Source

pub fn new(source: Arc<DataTable>) -> Self

Create a new view showing all data from the table

Source

pub fn with_columns(self, columns: Vec<usize>) -> Self

Create a view with specific columns

Source

pub fn hide_column(&mut self, display_index: usize) -> bool

Hide a column by display index (cannot hide pinned columns)

Source

pub fn hide_column_by_name(&mut self, column_name: &str) -> bool

Hide a column by name (cannot hide pinned columns)

Source

pub fn detect_empty_columns(&self) -> Vec<usize>

Detect columns that are entirely empty (NULL or empty string) in visible rows

Source

pub fn hide_empty_columns(&mut self) -> usize

Hide all columns that are entirely empty Returns the number of columns hidden

Source

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

Source

pub fn hide_all_columns(&mut self)

Hide all columns (clear all visible columns)

Source

pub fn has_visible_columns(&self) -> bool

Check if any columns are visible

Source

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

Source

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

Source

pub fn move_column_left_by_name(&mut self, column_name: &str) -> bool

Move a column by name to the left

Source

pub fn move_column_right_by_name(&mut self, column_name: &str) -> bool

Move a column by name to the right

Source

pub fn get_hidden_column_names(&self) -> Vec<String>

Get the names of hidden columns (columns in source but not visible)

Source

pub fn has_hidden_columns(&self) -> bool

Check if there are any hidden columns

Source

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)

Source

pub fn pin_column_by_name(&mut self, column_name: &str) -> Result<()>

Pin a column by name

Source

pub fn unpin_column(&mut self, display_index: usize) -> bool

Unpin a column by display index (move it back to regular visible columns)

Source

pub fn unpin_column_by_name(&mut self, column_name: &str) -> bool

Unpin a column by name

Source

pub fn clear_pinned_columns(&mut self)

Clear all pinned columns

Source

pub fn is_column_pinned(&self, display_index: usize) -> bool

Check if a column at display index is pinned

Source

pub fn get_pinned_columns(&self) -> &[usize]

Get pinned column indices

Source

pub fn get_pinned_column_names(&self) -> Vec<String>

Get the names of pinned columns

Source

pub fn get_display_columns(&self) -> Vec<usize>

Get display order of columns (pinned first, then visible)

Source

pub fn get_display_column_names(&self) -> Vec<String>

Get display column names in order (pinned first, then visible)

Source

pub fn set_max_pinned_columns(&mut self, max: usize)

Set maximum number of pinned columns

Source

pub fn with_rows(self, rows: Vec<usize>) -> Self

Create a view with specific rows

Source

pub fn with_limit(self, limit: usize, offset: usize) -> Self

Apply limit and offset

Source

pub fn filter<F>(self, predicate: F) -> Self
where F: Fn(&DataTable, usize) -> bool,

Filter rows based on a predicate

Source

pub fn apply_text_filter(&mut self, pattern: &str, case_sensitive: bool)

Apply a text filter to the view (filters visible rows)

Source

pub fn clear_filter(&mut self)

Clear all filters (both text and fuzzy) and restore all base rows

Source

pub fn has_filter(&self) -> bool

Check if any filter is active (text or fuzzy)

Source

pub fn get_filter_pattern(&self) -> Option<&str>

Get the current text filter pattern

Source

pub fn get_fuzzy_filter_pattern(&self) -> Option<&str>

Get the current fuzzy filter pattern

Source

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 ’)

Source

pub fn get_fuzzy_filter_indices(&self) -> Vec<usize>

Get indices of rows that match the fuzzy filter (for compatibility)

Source

pub fn get_visible_rows(&self) -> Vec<usize>

Get the visible row indices

Source

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

Source

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

Source

pub fn apply_multi_sort(&mut self, sort_columns: &[(usize, bool)]) -> Result<()>

Apply multi-column sorting Each tuple contains (source_column_index, ascending)

Source

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

Source

pub fn get_sort_state(&self) -> &SortState

Get the current sort state

Source

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

Source

pub fn clear_sort(&mut self)

Clear the current sort and restore original row order

Source

pub fn add_virtual_column(&mut self, virtual_column: VirtualColumn)

Add a virtual column to the view

Source

pub fn add_row_numbers(&mut self, position: VirtualColumnPosition)

Add a row number virtual column

Source

pub fn remove_virtual_columns(&mut self, name: &str)

Remove all virtual columns of a specific type by name

Source

pub fn toggle_row_numbers(&mut self)

Toggle row numbers on/off

Source

pub fn has_row_numbers(&self) -> bool

Check if row numbers are currently shown

Source

pub fn get_all_column_names(&self) -> Vec<String>

Get all column names including virtual columns in display order

Source

pub fn row_count(&self) -> usize

Get the number of visible rows

Source

pub fn column_count(&self) -> usize

Get the number of visible columns (including pinned and virtual)

Source

pub fn column_names(&self) -> Vec<String>

Get column names for visible columns (including virtual columns in correct positions)

Source

pub fn get_row(&self, index: usize) -> Option<DataRow>

Get a row by index (respecting limit/offset) including virtual columns

Source

pub fn get_rows(&self) -> Vec<DataRow>

Get all visible rows (respecting limit/offset)

Source

pub fn source(&self) -> &DataTable

Get the source DataTable

Source

pub fn source_arc(&self) -> Arc<DataTable>

Get the source DataTable as Arc (for memory-efficient sharing)

Source

pub fn is_column_visible(&self, index: usize) -> bool

Check if a column index is visible (either pinned or regular visible)

Source

pub fn visible_column_indices(&self) -> &[usize]

Get visible column indices (not including pinned)

Source

pub fn display_column_indices(&self) -> Vec<usize>

Get all display column indices (pinned + visible)

Source

pub fn visible_row_indices(&self) -> &[usize]

Get visible row indices (before limit/offset)

Source

pub fn shrink_to_fit(&mut self)

Optimize memory usage by shrinking vectors to fit

Source

pub fn search_columns(&mut self, pattern: &str)

Start or update column search with a pattern

Clear column search

Source

pub fn next_column_match(&mut self) -> Option<usize>

Go to next column search match

Source

pub fn prev_column_match(&mut self) -> Option<usize>

Go to previous column search match

Source

pub fn column_search_pattern(&self) -> Option<&str>

Get current column search pattern

Source

pub fn get_matching_columns(&self) -> &[(usize, String)]

Get matching columns from search

Source

pub fn current_column_match_index(&self) -> usize

Get current column match index

Source

pub fn get_current_column_match(&self) -> Option<usize>

Get current column match (visible column index)

Check if column search is active

Source

pub fn to_json(&self) -> Value

Export the visible data as JSON Returns an array of objects where each object represents a row

Source

pub fn to_csv(&self) -> Result<String>

Export the visible data as CSV string

Source

pub fn to_tsv(&self) -> Result<String>

Export the visible data as TSV (Tab-Separated Values) string

Source

pub fn get_column_values(&self, column_index: usize) -> Vec<String>

Get all values from a specific column (respecting filters and visible rows)

Source

pub fn get_cell_value( &self, row_index: usize, column_index: usize, ) -> Option<String>

Get a single cell value (respecting filters)

Source

pub fn get_row_values(&self, row_index: usize) -> Option<Vec<String>>

Get a row as string values (respecting filters)

Source

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()

Source

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)

Source

pub fn get_column_debug_info(&self) -> String

Get debug information about column visibility and ordering

Trait Implementations§

Source§

impl Clone for DataView

Source§

fn clone(&self) -> DataView

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 DataProvider for DataView

Source§

fn get_row(&self, index: usize) -> Option<Vec<String>>

Get a single row by index Returns None if the index is out of bounds
Source§

fn get_column_names(&self) -> Vec<String>

Get the column names/headers
Source§

fn get_row_count(&self) -> usize

Get the total number of rows
Source§

fn get_column_count(&self) -> usize

Get the total number of columns
Source§

fn get_column_widths(&self) -> Vec<usize>

Get the display width for each column Used for rendering column widths in the TUI
Source§

fn get_visible_rows(&self, start: usize, count: usize) -> Vec<Vec<String>>

Get multiple rows for efficient rendering This is an optimization to avoid multiple get_row calls
Source§

fn get_cell_value(&self, row: usize, col: usize) -> Option<String>

Get a single cell value Returns None if row or column index is out of bounds
Source§

fn get_display_value(&self, row: usize, col: usize) -> String

Get a display-formatted cell value Returns empty string if indices are out of bounds
Source§

fn get_column_type(&self, _column_index: usize) -> DataType

Get the data type of a specific column This should be cached/determined at load time, not computed on each call
Source§

fn get_column_types(&self) -> Vec<DataType>

Get data types for all columns Returns a vector where index corresponds to column index
Source§

impl Debug for DataView

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,