use crate::client::{ChError, ChExecutor};
use crate::codegen::rust_row_struct;
use crate::evolve::LiveColumn;
pub async fn introspect_columns(
exec: &impl ChExecutor,
table: &str,
) -> Result<Vec<LiveColumn>, ChError> {
exec.fetch_columns(table).await
}
pub async fn introspect_row_struct(
exec: &impl ChExecutor,
table: &str,
struct_name: &str,
) -> Result<String, ChError> {
let cols = introspect_columns(exec, table).await?;
let pairs: Vec<(String, String)> = cols.into_iter().map(|c| (c.name, c.type_name)).collect();
Ok(rust_row_struct(struct_name, &pairs))
}