Skip to main content

AggregateModel

Struct AggregateModel 

Source
pub struct AggregateModel {
    pub aggregate: Ident,
    pub vis: Visibility,
    pub krate: Path,
    pub krate_spelled: Option<LitStr>,
    pub upstream: Path,
    pub groups: Vec<Grouped>,
    pub measures: Vec<Measured>,
    pub triggers: TokenStream,
    pub stores: TokenStream,
    pub graphql: Option<TokenStream>,
}
Expand description

A validated aggregate declaration.

PLAIN, for the reason every model in this crate has plain fields: the derive today and a manifest front end later reach the same emitter.

§Three fields are TOKENS, and the passthrough is the journal’s law rather than laziness

triggers, stores and graphql are the words this declaration shares with the RECORD grammar, and they are carried UNINTERPRETED. The aggregate’s storage IS a record’s — the emission mints the (group…, measure…) row shape and hands it to the record pass, which is #[ingraph::journal]’s pattern verbatim — so reading a database block, a table = "…" or a poll(…) entry here would be a SECOND authority for one vocabulary, and two authorities for one vocabulary is how the two of them drift.

What the front end knows about them is only which WORDS start one, which it needs anyway to refuse a declaration that names no clock. Their teeth arrive with the record pass, at the same expansion that spends them.

Fields§

§aggregate: Ident

The declaration’s own name.

§vis: Visibility

The declaration’s visibility, carried for the types the emission mints beside it.

§krate: Path

Where ingraph lives, as crate = "…" named it or ::ingraph where it named none.

§krate_spelled: Option<LitStr>

The same, AS WRITTEN — the literal the record grammar is handed back when the emission mounts this declaration as a record.

Both halves are carried for #[ingraph::journal]’s stated reason: one authority for the path, and no round trip through a rendered path that could differ from the one that was written.

§upstream: Path

upstream(node = "…") — the ONE node whose rows are folded.

The edge and NOTHING ELSE, which is where this word differs from the derived indexes’ spelling of it: theirs carries the projection too, because a document is one upstream message and every field of it is read out of that message. Here only the GROUP columns are read out of a row — a measure’s column is FOLDED into being — so a projection written inside upstream(…) would claim a totality this kind does not have, and is refused pointing at GROUP.

§groups: Vec<Grouped>

The GROUP projection, in the order the declaration wrote its fields.

Never empty: a declaration with no group is refused before a model is built. The key this kind mints IS these columns, which is why a groupless aggregate has no shape here — it would be one keyless row, and the record family stores rows by key.

§measures: Vec<Measured>

The MEASURE columns, in the order the declaration wrote its fields. Never empty.

§triggers: TokenStream

Every poll(…) entry as written, comma-joined, ready to be handed to the record grammar.

Never empty: an aggregate recomputes ON A TRIGGER, so a declaration naming no clock would never run and its table would answer nothing, forever.

§stores: TokenStream

The store words and their two common entries as written, comma-joined — sqlite, postgres(schema = "…"), table = "…", rename = "…".

May be EMPTY, and the emptiness is answered by the record pass rather than here: a thing that holds rows names where they land is the record grammar’s sentence, and this grammar knowing only which words START a store has nothing of its own to add to it.

§graphql: Option<TokenStream>

graphql(…) as written, or None where the declaration named no backend.

Implementations§

Source§

impl AggregateModel

Source

pub fn columns(&self) -> impl Iterator<Item = &Ident>

The declaration’s columns in ROW ORDER — every group column, then every measure.

The row shape the emission mints is these columns in this order, so the walk is the model’s rather than each reader’s: two readers ordering one row shape differently is a table whose columns depend on who asked. Groups lead because they are the KEY, and a key is a row’s first columns everywhere else in this framework.

Trait Implementations§

Source§

impl Clone for AggregateModel

Source§

fn clone(&self) -> Self

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 AggregateModel

Source§

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

Formats the value using the given formatter. Read more

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.