Skip to main content

DatasetViewer

Struct DatasetViewer 

Source
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

Source

pub fn new(adapter: DatasetAdapter) -> Self

Create a new viewer with default dimensions

§Arguments
  • adapter - The dataset adapter to display
Source

pub fn with_dimensions(adapter: DatasetAdapter, width: u16, height: u16) -> Self

Create a new viewer with specific dimensions

§Arguments
  • adapter - The dataset adapter to display
  • width - Display width in characters
  • height - Display height in rows (including header)
Source

pub fn set_dimensions(&mut self, width: u16, height: u16)

Update display dimensions

Recalculates column widths and scroll state.

Source

pub fn scroll_offset(&self) -> usize

Get the current scroll offset

Source

pub fn set_scroll_offset(&mut self, offset: usize)

Set the scroll offset

Source

pub fn row_count(&self) -> usize

Get total row count

Source

pub fn visible_row_count(&self) -> u16

Get visible row count

Source

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

Get the currently selected row

Source

pub fn select_row(&mut self, row: usize)

Select a specific row

Source

pub fn clear_selection(&mut self)

Clear selection

Source

pub fn is_empty(&self) -> bool

Check if the dataset is empty

Source

pub fn adapter(&self) -> &DatasetAdapter

Get the adapter reference

Source

pub fn column_widths(&self) -> &[u16]

Get column widths

Source

pub fn scroll_down(&mut self)

Scroll down by one row

Source

pub fn scroll_up(&mut self)

Scroll up by one row

Source

pub fn page_down(&mut self)

Scroll down by one page

Source

pub fn page_up(&mut self)

Scroll up by one page

Source

pub fn home(&mut self)

Jump to first row

Source

pub fn end(&mut self)

Jump to last page

Source

pub fn select_next(&mut self)

Select next row

Source

pub fn select_prev(&mut self)

Select previous row

Source

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

Get column headers

Source

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.

Source

pub fn is_row_selected(&self, global_row: usize) -> bool

Check if a row is currently selected

Source

pub fn needs_scrollbar(&self) -> bool

Check if scrollbar should be shown

Source

pub fn scrollbar_position(&self) -> f32

Get scrollbar position (0.0 to 1.0)

Source

pub fn scrollbar_size(&self) -> f32

Get scrollbar size (0.0 to 1.0)

Source

pub fn render_header_line(&self) -> String

Render header line as a string

Source

pub fn render_row_line(&self, viewport_row: usize) -> Option<String>

Render a data row as a string

Source

pub fn viewport_to_data_row(&self, viewport_row: usize) -> usize

Get the data row index for a viewport row

Source

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

Source

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.

Source

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

Source§

fn clone(&self) -> DatasetViewer

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 Debug for DatasetViewer

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<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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