DataTable

Struct DataTable 

Source
pub struct DataTable {
    pub name: String,
    pub columns: Vec<DataColumn>,
    pub rows: Vec<DataRow>,
    pub metadata: HashMap<String, String>,
}
Expand description

The main DataTable structure

Fields§

§name: String§columns: Vec<DataColumn>§rows: Vec<DataRow>§metadata: HashMap<String, String>

Implementations§

Source§

impl DataTable

Source

pub fn new(name: impl Into<String>) -> Self

Source

pub fn dual() -> Self

Create a DUAL table (similar to Oracle’s DUAL) with one row and one column Used for evaluating expressions without a data source

Source

pub fn add_column(&mut self, column: DataColumn) -> &mut Self

Source

pub fn add_row(&mut self, row: DataRow) -> Result<(), String>

Source

pub fn get_column(&self, name: &str) -> Option<&DataColumn>

Source

pub fn get_column_index(&self, name: &str) -> Option<usize>

Source

pub fn column_count(&self) -> usize

Source

pub fn row_count(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

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

Get column names as a vector

Source

pub fn infer_column_types(&mut self)

Infer and update column types based on data

Source

pub fn get_value(&self, row: usize, col: usize) -> Option<&DataValue>

Get a value at specific row and column

Source

pub fn get_value_by_name( &self, row: usize, col_name: &str, ) -> Option<&DataValue>

Get a value by row index and column name

Source

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

Convert to a vector of string vectors (for display/compatibility)

Source

pub fn get_stats(&self) -> DataTableStats

Get table statistics

Source

pub fn debug_dump(&self) -> String

Generate a debug dump string for display

Source

pub fn estimate_memory_size(&self) -> usize

Source

pub fn from_query_response( response: &QueryResponse, table_name: &str, ) -> Result<Self, String>

V46: Create DataTable from QueryResponse This is the key conversion function that bridges old and new systems

Source

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

Get a single row by index

Source

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

V50: Get a single row as strings

Source

pub fn pretty_print(&self) -> String

Pretty print the DataTable with a nice box drawing

Source

pub fn get_schema_summary(&self) -> String

Get a schema summary of the DataTable

Source

pub fn get_schema_info(&self) -> Vec<(String, String, bool, usize)>

Get detailed schema information as a structured format

Source

pub fn reserve_rows(&mut self, additional: usize)

Reserve capacity for rows to avoid reallocations

Source

pub fn shrink_to_fit(&mut self)

Shrink vectors to fit actual data (removes excess capacity)

Source

pub fn get_memory_usage(&self) -> usize

Get actual memory usage estimate (more accurate than estimate_memory_size)

Trait Implementations§

Source§

impl Clone for DataTable

Source§

fn clone(&self) -> DataTable

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 DataTable

Implementation of DataProvider for DataTable This allows DataTable to be used wherever DataProvider trait is expected

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_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_column_widths(&self) -> Vec<usize>

Get the display width for each column Used for rendering column widths in the TUI
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 DataTable

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<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
Source§

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