Skip to main content

DataStore

Trait DataStore 

Source
pub trait DataStore: Send {
    // Required methods
    fn ingest_csv(&self, path: &Path, table: &str) -> Result<IngestReport>;
    fn query(&self, sql: &str, row_cap: usize) -> Result<QueryResult>;
    fn summarize(&self, table: &str) -> Result<TableSummary>;
    fn list_tables(&self) -> Result<Vec<TableInfo>>;
    fn backend_name(&self) -> &'static str;
}
Expand description

The headless data engine (Phase 21).

The seam every later step builds on: the MCP adapter (21.2) wraps a dyn DataStore, and the DuckDB backend (21.8) implements this same trait so no tool signature changes. Send is required so the trait object can move across the MCP server’s task boundary; methods take &self because the SQLite backend shares one connection behind a mutex.

See docs/design/centaur-data-scientist.md.

Required Methods§

Source

fn ingest_csv(&self, path: &Path, table: &str) -> Result<IngestReport>

Load path (a CSV) into table, dropping and recreating the table.

Headers become column names; per-column dtype is inferred from the data (Phase 21 — crate::ingest). Empty cells are NULL. table is validated as a safe identifier first (DataError::InvalidIdentifier); an empty file is DataError::EmptyCsv.

Source

fn query(&self, sql: &str, row_cap: usize) -> Result<QueryResult>

Run sql and return up to row_cap rows with an honest truncated flag (Phase 21 — see QueryResult). row_cap == 0 returns no rows and truncated == true iff the query produced any.

Source

fn summarize(&self, table: &str) -> Result<TableSummary>

Compute schema + per-column statistics (pandas-style describe for numeric columns) for table (DataError::NoSuchTable if absent).

Source

fn list_tables(&self) -> Result<Vec<TableInfo>>

List the user tables (excluding the engine’s __datasets metadata and SQLite’s internal tables) with their row counts and source paths.

Source

fn backend_name(&self) -> &'static str

A short, stable backend identifier ("sqlite" today; "duckdb" at step 21.8) for diagnostics and tool output.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§