Rindle docs and package mapSkip to main content

Schema

Struct Schema 

pub struct Schema {
    pub columns: Vec<Box<str>>,
    pub column_types: Vec<ValueType>,
    pub primary_key: Vec<usize>,
    pub sort: Vec<(usize, bool)>,
    pub relationships: Vec<RelDef>,
    pub singular: bool,
    pub projection: Option<Vec<usize>>,
}
Expand description

The view / pipeline schema: a table’s columns + key + sort plus the per-query relationship slots and .one() shape the dataflow and materialized view carry. A source table is registered with the lighter SourceSchema (no relationships, no singular); the build path widens that to a Schema and fills relationships from the query AST — never from a source declaration, of which there are none.

Fields§

§columns: Vec<Box<str>>

Column names. Owned (Vec<Box<str>>) so a runtime-supplied schema (the JS wasm boundary, WS01.3) can construct it without leaking Box::leak’d 'static strings. Schema::new still takes Vec<&str>, so existing vec!["id", …] literal call sites coerce in unchanged.

§column_types: Vec<ValueType>

Declared logical column types, parallel to columns (design 226 §4.1). Schema::new defaults every column to ValueType::Number — the untyped/legacy declaration; homes that know the real types (the SQLite replica’s decltype discovery, the SQLite leaf’s ColumnDefs) install them via Schema::with_column_types. The engine consults these only for exact-integer behavior, so a defaulted non-numeric column is inert — the value boundary keeps its own per-leaf typing channel.

§primary_key: Vec<usize>§sort: Vec<(usize, bool)>§relationships: Vec<RelDef>

Declared outgoing relationships (slot = list index). Empty for a leaf table that is never a join parent. A join resolves its rel_name to a slot here at build time (Schema::rel_slot), so the hot path is index-addressed.

§singular: bool

.one() shape for this level of the materialized view — lowered from the query’s Ast::one by view_schema. When set, the result boundary presents this level as a single object (or null/absent) instead of an array; the engine tree itself stays plural at every level. Always false for a source / table schema.

§projection: Option<Vec<usize>>

Projection (PROJECTION-SUPPORT-DESIGN.md §6). None ⇒ the view reports every column ('*'); Some(cols) ⇒ the view reports only these base ColIds, in this order — the lowering of the query’s Ast::select. columns stays the full, positional column list (rows are full width everywhere on the client, §2.1); projection is applied only at the result boundary (the marshal reads columns[col] / row[col] for each col in this list). The PK / sort indices therefore remain valid in the full column space regardless of what the view reports.

Implementations§

§

impl Schema

pub fn new( columns: Vec<&str>, primary_key: Vec<usize>, sort: Vec<(usize, bool)>, ) -> Schema

Construct a relationship-free schema (the common case). Use Schema::with_relationships to declare relationships for a join parent. Keeps the 3-field call sites terse now that relationships exists.

pub fn with_relationships(self, relationships: Vec<RelDef>) -> Schema

Builder: declare this table’s outgoing relationships (slot = list index).

pub fn with_column_types(self, column_types: Vec<ValueType>) -> Schema

Builder: install the declared column types (parallel to columns, design 226 §4.1), replacing Schema::new’s all-Number default.

pub fn rel_child(&self, slot: RelId) -> Option<&Schema>

The target Schema of relationship slot, or None if the slot is undeclared or join-only (no child schema attached).

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

Resolve a column name to its ColId — the builder’s name→index lowering (08). None if the column is not in this schema.

pub fn rel_slot(&self, name: &str) -> Option<RelId>

Resolve a relationship name to its RelId slot. None if undeclared.

Trait Implementations§

§

impl Clone for Schema

§

fn clone(&self) -> Schema

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
§

impl Debug for Schema

§

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

Formats the value using the given formatter. Read more
§

impl From<SourceSchema> for Schema

§

fn from(s: SourceSchema) -> Schema

Converts to this type from the input type.

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.