pub struct TabularData {
pub headers: Vec<String>,
pub rows: Vec<Vec<Value>>,
pub has_header: bool,
pub key: Vec<String>,
pub column_types: Vec<Option<String>>,
pub column_metadata: Vec<Value>,
pub table_metadata: Value,
}Expand description
Format-neutral tabular data: an ordered list of records with a shared column schema. Produced by CSV, JSON record arrays, JSONL, Excel, Parquet, DB, and other tabular parsers; consumed by tabular writers, compaction rules, and extractors.
This is the codec type for the tabular_v1 artifact format.
Serialize with serde_json::to_vec, deserialize with serde_json::from_slice.
The shape spectrum (rectangular?, named columns?, typed cells?) is derived
from the data via TabularData::is_rectangular,
TabularData::has_named_columns, and the cell Value variants — rules gate
their behavior on those facts rather than on artifact subtypes.
Fields§
§headers: Vec<String>Column names. For headerless sources these are synthesized positional
labels and has_header is false.
rows: Vec<Vec<Value>>§has_header: boolWhether the source supplied real column names (CSV header, object keys).
key: Vec<String>Declared identity column names, in order. Empty when the source declares no key; drives keyed row alignment when present.
column_types: Vec<Option<String>>Optional source-declared type per column (parallel to headers), when the
source format carries one (DB, Parquet, Stata). Empty means “none”.
column_metadata: Vec<Value>Optional per-column metadata bag (parallel to headers), when the source
format carries column-scoped facts a generic tabular consumer would not
otherwise see — labels, display formats, value-label set names, units.
Each entry is an open object (or Null for a column with no metadata).
Empty means “none”. This is tier 1 of the tiered-metadata design (see the
tiered-artifact-metadata ADR): facts keyed to a column.
table_metadata: ValueOptional table-scoped metadata bag — facts about this table as a whole
that are not per-column and not per-file (a single-table file folds its
source-format facts here; a table inside a multi-table container carries
only its own facts, e.g. dataset name/label). Null means “none”. This
is tier 2 of the tiered-metadata design.
Implementations§
Source§impl TabularData
impl TabularData
Sourcepub fn from_string_rows(headers: Vec<String>, rows: Vec<Vec<String>>) -> Self
pub fn from_string_rows(headers: Vec<String>, rows: Vec<Vec<String>>) -> Self
Construct from all-string cells (CSV and other untyped sources). Cells are
wrapped in Value::String; the result is byte-identical in behavior to
the legacy all-string tabular model.
Sourcepub fn new(headers: Vec<String>, rows: Vec<Vec<Value>>) -> Self
pub fn new(headers: Vec<String>, rows: Vec<Vec<Value>>) -> Self
Construct from typed rows with a named header.
Sourcepub fn with_column_metadata(self, column_metadata: Vec<Value>) -> Self
pub fn with_column_metadata(self, column_metadata: Vec<Value>) -> Self
Attach tier-1 per-column metadata (parallel to headers). Builder-style
so producers can enrich a table without restating every field.
Sourcepub fn with_table_metadata(self, table_metadata: Value) -> Self
pub fn with_table_metadata(self, table_metadata: Value) -> Self
Attach tier-2 table-scoped metadata.
pub fn column_index(&self, name: &str) -> Option<usize>
pub fn column_values(&self, name: &str) -> Option<Vec<&Value>>
Sourcepub fn is_rectangular(&self) -> bool
pub fn is_rectangular(&self) -> bool
Every row has arity equal to the column count.
Sourcepub fn has_named_columns(&self) -> bool
pub fn has_named_columns(&self) -> bool
The source supplied real, usable column names.
Sourcepub fn stable_columns(&self) -> bool
pub fn stable_columns(&self) -> bool
Columns can be identified across rows and snapshots — the precondition for cell-grain and column-grain edits. Otherwise the writer degrades to row-grain output.
pub fn to_csv(&self) -> String
Trait Implementations§
Source§impl Clone for TabularData
impl Clone for TabularData
Source§fn clone(&self) -> TabularData
fn clone(&self) -> TabularData
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TabularData
impl Debug for TabularData
Source§impl<'de> Deserialize<'de> for TabularData
impl<'de> Deserialize<'de> for TabularData
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for TabularData
impl PartialEq for TabularData
Source§fn eq(&self, other: &TabularData) -> bool
fn eq(&self, other: &TabularData) -> bool
self and other values to be equal, and is used by ==.