#[source]Expand description
Declare an ORIGIN — and hold its mutation word and its type Mutation seat to each other.
#[ingraph::source(async, mutation(node = "WatchOps"))]
pub struct Watch { roots: Vec<PathBuf> }
impl AsyncSource for Watch {
type Options = WatchOptions;
type Yield = Change;
type Mutation = WatchOps; // the word above, as a TYPE
type Error = WatchError;
async fn build(ctx: &Resources, options: WatchOptions) -> Result<Self, Self::Error> { … }
async fn run(self, ctx: Context, feed: Feed<Change>, control: Control<WatchOpsCommand>)
-> Result<Fin, Self::Error> { … }
}§THE DOUBLE ENTRY, which is the whole of what this word emits
A source’s command face is written twice — once as a WORD, which is what a declaration says, and
once as a TYPE, which is what a Control line resolves through
— and neither spelling can be dropped: an attribute macro cannot write somebody else’s impl,
and an impl is not a declaration. So this expansion writes the JOIN between them, and the join
is checked in BOTH directions:
| written | what happens |
|---|---|
| the word and the matching seat | it compiles |
the word, and a seat naming something else (() included) | E0271 at the WORD |
| no word, and a seat naming a node | E0271 at the DECLARATION |
no word, and type Mutation = () | it compiles |
The third row is what a single-entry design would have lost: a source that mounted a node and forgot to say so would publish no wire face, and a missing word looks exactly like a source nobody controls.
§ONE command face per source
mutation(…) may be written at most once. A second one is refused with the sentence that names
the day it arrives — more words go in the NODE, and the mount widens when two vocabularies truly
diverge — because the wire face is per-FIELD, so N nodes and one node with N fields are the same
schema and the same author experience.
§Attributes
async— this origin’s body is awaited, so the bound namesAsyncSource. Without it the bound namesSource, the blocking face, per the dual-mode law’s word-selects-face rule.mutation(node = "path::to::Node")— the mutation node whose fields are this origin’s command vocabulary. Omitted for an origin nobody controls, whose seat is().crate = "path::to::ingraph"— whereingraphlives, exactly asrecord’s.
§What it emits
| item | content |
|---|---|
| the author’s host, echoed | unchanged but for the markers this macro consumed |
one anonymous const | the double entry — a bound over the declared type naming the mounted node, spent at the word |
impl DeclaredOrigin | the RECORD a launch walk mounts it through — its face as a TYPE, and the node it controls as a word |
And nothing else. No command enum, no MutationNode row, no resolver: those are the NODE’s own
declaration’s, and this one has never seen its tokens.
§THE RECORD is what makes a mount declaration-driven
A launch walk that mounts an origin sees a TYPE and nothing else, so the record is how the
async word reaches it: type Mode selects the driver, and one door then serves both faces —
Blueprint::origin::<Watch>("watch") enters the arrangement and
Ignition::origin_declared::<Watch>(…) puts it on an engine, neither of them naming a face. An
origin that publishes to nobody is refused before anything ignites, by the pure-leaf rule that
was already there.
It is a PUBLIC seam: a hand-written origin writes the impl in three lines and is mounted the same way. Nothing here is obliged to have come through this macro.
§ONE OPTIONS SEAT, and it is the face’s own
The type Options above is what a deployment’s [watch] section holds, and
Creation::origin is what hands it to build. There is no second seat to keep in step: an
origin used to be constructed through
AsyncConstructor because build signed a
Context the create stage has not got, and the window moved to
Resources so the face’s own door could be the one the
framework calls.
§Refusals
| written | refused because |
|---|---|
a second mutation(…) | one command face per source — the mount widens the day two vocabularies diverge |
mutation, mutation() or a block with no node | an origin nobody controls omits the word; one that is controlled names the node |
mutation(node = Node) | the word names a TYPE this declaration cannot resolve, so it is quoted |
a second async | one origin wears one face |
| a generic parameter | the expansion states ONE bound over ONE origin |