Skip to main content

TabularData

Struct TabularData 

Source
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: bool

Whether 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: Value

Optional 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

Source

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.

Source

pub fn new(headers: Vec<String>, rows: Vec<Vec<Value>>) -> Self

Construct from typed rows with a named header.

Source

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.

Source

pub fn with_table_metadata(self, table_metadata: Value) -> Self

Attach tier-2 table-scoped metadata.

Source

pub fn column_index(&self, name: &str) -> Option<usize>

Source

pub fn column_values(&self, name: &str) -> Option<Vec<&Value>>

Source

pub fn is_rectangular(&self) -> bool

Every row has arity equal to the column count.

Source

pub fn has_named_columns(&self) -> bool

The source supplied real, usable column names.

Source

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.

Source

pub fn to_csv(&self) -> String

Trait Implementations§

Source§

impl Clone for TabularData

Source§

fn clone(&self) -> TabularData

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TabularData

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for TabularData

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for TabularData

Source§

fn eq(&self, other: &TabularData) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for TabularData

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for TabularData

Source§

impl StructuralPartialEq for TabularData

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,