pub struct DatasetViewer { /* private fields */ }Expand description
A scrollable table view for displaying Arrow datasets
The viewer provides:
- Scrollable rows with keyboard navigation
- Column headers with field names
- Selected row highlighting
- Automatic column width calculation
- Truncation with ellipsis for long values
§Example
let adapter = DatasetAdapter::from_dataset(&dataset)?;
let viewer = DatasetViewer::new(adapter);
// Handle keyboard input
viewer.scroll_down();
viewer.select_row(5);
// Get visible data for rendering
let headers = viewer.headers();
let rows = viewer.visible_rows();Implementations§
Source§impl DatasetViewer
impl DatasetViewer
Sourcepub fn new(adapter: DatasetAdapter) -> Self
pub fn new(adapter: DatasetAdapter) -> Self
Sourcepub fn with_dimensions(adapter: DatasetAdapter, width: u16, height: u16) -> Self
pub fn with_dimensions(adapter: DatasetAdapter, width: u16, height: u16) -> Self
Create a new viewer with specific dimensions
§Arguments
adapter- The dataset adapter to displaywidth- Display width in charactersheight- Display height in rows (including header)
Sourcepub fn set_dimensions(&mut self, width: u16, height: u16)
pub fn set_dimensions(&mut self, width: u16, height: u16)
Update display dimensions
Recalculates column widths and scroll state.
Sourcepub fn scroll_offset(&self) -> usize
pub fn scroll_offset(&self) -> usize
Get the current scroll offset
Sourcepub fn set_scroll_offset(&mut self, offset: usize)
pub fn set_scroll_offset(&mut self, offset: usize)
Set the scroll offset
Sourcepub fn visible_row_count(&self) -> u16
pub fn visible_row_count(&self) -> u16
Get visible row count
Sourcepub fn selected_row(&self) -> Option<usize>
pub fn selected_row(&self) -> Option<usize>
Get the currently selected row
Sourcepub fn select_row(&mut self, row: usize)
pub fn select_row(&mut self, row: usize)
Select a specific row
Sourcepub fn clear_selection(&mut self)
pub fn clear_selection(&mut self)
Clear selection
Sourcepub fn adapter(&self) -> &DatasetAdapter
pub fn adapter(&self) -> &DatasetAdapter
Get the adapter reference
Sourcepub fn column_widths(&self) -> &[u16]
pub fn column_widths(&self) -> &[u16]
Get column widths
Sourcepub fn scroll_down(&mut self)
pub fn scroll_down(&mut self)
Scroll down by one row
Sourcepub fn select_next(&mut self)
pub fn select_next(&mut self)
Select next row
Sourcepub fn select_prev(&mut self)
pub fn select_prev(&mut self)
Select previous row
Sourcepub fn visible_rows_data(&self) -> Vec<Vec<String>>
pub fn visible_rows_data(&self) -> Vec<Vec<String>>
Get visible rows as formatted strings
Returns a vector of rows, where each row is a vector of cell strings.
Sourcepub fn is_row_selected(&self, global_row: usize) -> bool
pub fn is_row_selected(&self, global_row: usize) -> bool
Check if a row is currently selected
Sourcepub fn needs_scrollbar(&self) -> bool
pub fn needs_scrollbar(&self) -> bool
Check if scrollbar should be shown
Sourcepub fn scrollbar_position(&self) -> f32
pub fn scrollbar_position(&self) -> f32
Get scrollbar position (0.0 to 1.0)
Sourcepub fn scrollbar_size(&self) -> f32
pub fn scrollbar_size(&self) -> f32
Get scrollbar size (0.0 to 1.0)
Sourcepub fn render_header_line(&self) -> String
pub fn render_header_line(&self) -> String
Render header line as a string
Sourcepub fn render_row_line(&self, viewport_row: usize) -> Option<String>
pub fn render_row_line(&self, viewport_row: usize) -> Option<String>
Render a data row as a string
Sourcepub fn viewport_to_data_row(&self, viewport_row: usize) -> usize
pub fn viewport_to_data_row(&self, viewport_row: usize) -> usize
Get the data row index for a viewport row
Sourcepub fn search(&mut self, query: &str) -> Option<usize>
pub fn search(&mut self, query: &str) -> Option<usize>
Search for a substring and select the first matching row
Returns the row index if found, None otherwise. This is a linear scan suitable for datasets <100k rows (F101).
Sourcepub fn search_next(&mut self, query: &str) -> Option<usize>
pub fn search_next(&mut self, query: &str) -> Option<usize>
Continue search from current position
Wraps around to beginning if no match found after current row.
Sourcepub fn render_lines(&self) -> Vec<String>
pub fn render_lines(&self) -> Vec<String>
Render complete output as lines
Returns header followed by visible data rows.
Trait Implementations§
Source§impl Clone for DatasetViewer
impl Clone for DatasetViewer
Source§fn clone(&self) -> DatasetViewer
fn clone(&self) -> DatasetViewer
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for DatasetViewer
impl !RefUnwindSafe for DatasetViewer
impl Send for DatasetViewer
impl Sync for DatasetViewer
impl Unpin for DatasetViewer
impl UnsafeUnpin for DatasetViewer
impl !UnwindSafe for DatasetViewer
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