pub trait DataSource: Send + Sync {
// Required methods
fn query(&self, sql: &str) -> Result<DataSourceQueryResponse>;
fn query_with_options(
&self,
sql: &str,
case_insensitive: bool,
) -> Result<DataSourceQueryResponse>;
fn get_schema(&self) -> Option<HashMap<String, Vec<String>>>;
fn get_table_name(&self) -> String;
fn get_row_count(&self) -> usize;
fn is_case_insensitive(&self) -> bool;
fn set_case_insensitive(&mut self, case_insensitive: bool);
fn clone_box(&self) -> Box<dyn DataSource>;
}
Expand description
Trait for abstracting data sources (CSV, JSON, Database, etc.) This allows the TUI to work with data without knowing the specific source
Required Methods§
Sourcefn query(&self, sql: &str) -> Result<DataSourceQueryResponse>
fn query(&self, sql: &str) -> Result<DataSourceQueryResponse>
Execute a SQL-like query against the data source
Sourcefn query_with_options(
&self,
sql: &str,
case_insensitive: bool,
) -> Result<DataSourceQueryResponse>
fn query_with_options( &self, sql: &str, case_insensitive: bool, ) -> Result<DataSourceQueryResponse>
Execute a query with case-insensitive matching
Sourcefn get_schema(&self) -> Option<HashMap<String, Vec<String>>>
fn get_schema(&self) -> Option<HashMap<String, Vec<String>>>
Get the schema (table names and their columns)
Sourcefn get_table_name(&self) -> String
fn get_table_name(&self) -> String
Get the primary table name
Sourcefn get_row_count(&self) -> usize
fn get_row_count(&self) -> usize
Get total row count (unfiltered)
Sourcefn is_case_insensitive(&self) -> bool
fn is_case_insensitive(&self) -> bool
Check if data source is case-insensitive
Sourcefn set_case_insensitive(&mut self, case_insensitive: bool)
fn set_case_insensitive(&mut self, case_insensitive: bool)
Set case sensitivity
Sourcefn clone_box(&self) -> Box<dyn DataSource>
fn clone_box(&self) -> Box<dyn DataSource>
Clone the data source into a boxed trait object