use std::path::Path;
#[derive(Debug, Clone, PartialEq)]
pub enum QueryValue {
Null,
Integer(i64),
Real(f64),
Text(String),
}
#[derive(Debug, Clone, PartialEq)]
pub struct QueryResult {
pub columns: Vec<String>,
pub rows: Vec<Vec<QueryValue>>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct QueryParam {
pub name: String,
pub value: QueryValue,
}
#[derive(Debug, Clone, Copy)]
pub struct WorkbookInput<'a> {
pub path: &'a Path,
pub sheet_name: Option<&'a str>,
pub table_name: Option<&'a str>,
pub explicit_format: Option<&'a str>,
}
#[derive(Debug, Clone)]
pub struct TypeInferenceOptions {
pub infer_types: bool,
pub decimal_comma: bool,
pub date_format: Option<String>,
pub null_values: Vec<String>,
pub true_values: Vec<String>,
pub false_values: Vec<String>,
}
impl Default for TypeInferenceOptions {
fn default() -> Self {
Self {
infer_types: true,
decimal_comma: false,
date_format: None,
null_values: vec![String::new()],
true_values: vec!["true".to_owned()],
false_values: vec!["false".to_owned()],
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum HeaderCase {
Snake,
Camel,
Pascal,
ScreamingSnake,
}
#[derive(Debug, Clone, Default)]
pub struct InputNormalizationOptions {
pub trim: bool,
pub skip_empty_rows: bool,
pub normalize_headers: bool,
pub header_case: Option<HeaderCase>,
pub dedupe_headers: bool,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum JsonMode {
#[default]
Array,
Object,
Flatten,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum XmlMode {
#[default]
Rows,
Descendants,
Attributes,
}
#[derive(Debug, Clone, Default)]
pub struct ExtractionOptions {
pub json_mode: JsonMode,
pub xml_mode: XmlMode,
}
#[derive(Debug, Clone, PartialEq)]
pub enum InferredType {
Integer,
Real,
Text,
Mixed,
}
impl InferredType {
pub fn as_str(&self) -> &'static str {
match self {
InferredType::Integer => "INTEGER",
InferredType::Real => "REAL",
InferredType::Text => "TEXT",
InferredType::Mixed => "MIXED",
}
}
}
#[derive(Debug, Clone)]
pub struct ColumnInfo {
pub table_name: String,
pub column_name: String,
pub inferred_type: InferredType,
pub nullable: bool,
}
#[derive(Debug, Clone)]
pub struct ColumnStats {
pub distinct_count: usize,
pub min_value: Option<String>,
pub max_value: Option<String>,
}
#[derive(Debug, Clone)]
pub struct TableSummary {
pub table_name: String,
pub source_path: String,
pub source_selector: Option<String>,
pub row_count: usize,
pub columns: Vec<ColumnInfo>,
pub sample_rows: Vec<Vec<QueryValue>>,
pub warnings: Vec<String>,
pub column_stats: Option<Vec<ColumnStats>>,
}