Skip to main content

Receipts

Trait Receipts 

Source
pub trait Receipts {
    type Receipt;
}
Available on crate feature runtime only.
Expand description

WHAT THIS MESSAGE’S RECEIPT IS — the type a consumer hands back for one item of it, declared once by the message that is GIVEN.

The ack says the item LANDED; the receipt says what it landed AS. A seat upserts the row, the natural key it matched keeps the id it already had, and only the seat knows what that id is — so the value rides back on the one channel that already goes to exactly the right party (Emitter::receipt, Ack::receipting, and the producer’s Acked). This trait is where the two ends of that channel learn to name the SAME type without either of them writing it twice.

ⓘ
impl Receipts for SceneOpen {
  type Receipt = SceneId;
}

§The self type is the MESSAGE, and that is the whole ruling

The seat shipped keyed on the NODE — impl Receipts for Scene, the consumer stating what IT hands back — and the subject was wrong. A receipt answers the item that was GIVEN, so the question belongs to what was given: one message asks one question, and every seat on the far end of that edge answers the same one. Keyed on the node, two seats over one message each declared the answer’s type and the two could disagree about a question neither of them asked; keyed on the message there is one declaration and nothing to keep in step.

What it buys the PRODUCER is the inference, and the inference is the point: feed.give_acked(open)?.receipt() projects <SceneOpen as Receipts>::Receipt off the message it just gave — no turbofish, no node named, and it reads the same from any Feed whatever is mounted downstream. A producer cannot name the consumer of its own edge. It always knows what it gave.

§It is a SIBLING trait and not a member of anything

A type Receipt = (); seat on Operator itself was the first shape tried, and the language refuses it: associated-type defaults are unstable (E0658), so the seat could not be defaulted — and an undefaulted member is a line every declaration in this tree would have to write to say a thing almost none of them does. The same wall is written down one layer over at Declared::Pair, where the cost was accepted because a pair is a fact EVERY declaration has; a receipt is a fact almost none has, and the two answers differ for exactly that reason.

The three roads that were refused, and why:

  • the defaulted member — E0658, above. It is not a matter of taste;
  • an undefaulted member — every declaration pays a line for a seat it leaves empty, and a seat every author fills with the same nothing is ceremony rather than a declaration;
  • a runtime registry — a map from message to receipt type, filled at launch. It moves the mistake from compile time to start-up and gives the compiler nothing to check.

What is left is the OPT-IN SIBLING: a message that is waited on states one impl, a message that is not writes nothing at all, and the seat still lands in the type system where a projection can read it. Zero ceremony for every message nobody waits on is not a side effect of this shape — it is the whole of why the shape was chosen.

§Two roads to the impl, and both are first class

The receipt = "…" word on a MESSAGE-MINTING declaration — #[ingraph::entity(receipt = "…")], with record and aggregate beside it — emits exactly the impl above, and it is the DEFAULT road. Writing the impl by hand is equally legal and equally complete, and it is the road a GENERIC framework message has to take: a message carrying a parameter of its own — a scene handle whose type the mounting application chooses — has no concrete path a quoted word could name, and says impl<S> Receipts for SceneOpen<S> { type Receipt = S; } instead. The word reaches every message whose answer is a type somebody wrote down; the hand impl reaches the rest.

The word is a DECLARATION rather than a restatement — there is no other place a declaration could state its receipt — so it does not fall under the rule that bars a macro word from repeating a fact an impl already carries. It is refused by name on a declaration that mints no message: an operator computes and puts its Out on the edge rather than itself, and a derived index carries an upstream’s key, so neither has an item a producer could be parked on.

§WHAT THE SEAT BUYS: five doors that stop guessing, and one that no longer needs a door

Each is the _of twin of a door that already existed, and every one of them names the MESSAGE where its sibling named a TYPE. Same slot, same box, same wire — the declaration replaces a turbofish the caller invented with a projection the compiler resolves:

FIVE and not six, and the missing row is the producer’s. Acked<M> carries the message it was opened with, so Acked::receipt IS the declared door — there is no turbofish left for an _of twin to remove, and the three that existed (receipt_of, receipt_of_within, receipt_of_async) are gone rather than kept as aliases. The five above keep theirs for the opposite reason: each hangs off a K-keyed answer that names no message type at all, so the one door that COULD infer is the one that does.

The three STATING doors span both faces on purpose: a buffered body reaches Emitter, and a StreamOperator body — which is handed its delivery’s custody and never sees an Emitter — reaches Ack or Owed. A seat only the buffered face could use would have left the streamed half of the framework unable to be checked at all.

§WHAT IT DOES NOT BUY, stated so nothing here is read as more than it is

The wire is still dyn Any. The box crosses erased whatever any declaration says — that is Settled’s own law, and it is what lets one edge’s consumers each name their own type — so Unreceipted::Mismatched is still reachable and is still the right answer. What the seat removes is the GUESS, not the erasure: the type is no longer something either end invents, so the two ends can no longer disagree by typo. Where a message declared nothing, the open doors are exactly what they were.

And a seat still has to STATE its answer. The declaration says what the answer’s type is; it does not make a consumer produce one. A seat that stays silent over a message that declares a receipt is Unreceipted::Silent at the producer, by name and without hanging — which is the honest report of a graph whose landing seat is not wired.

§Notified is a DIFFERENT AXIS, not a restatement

Notified is the DOWNSTREAM’s choice — whether a consumer’s edge carries the whole message or only the landed key — and it is spelled notify in the grammar, matching its own name. This is the UPSTREAM’s answer, travelling backward along the ack of a give that asked for one. Nothing reads both.

Required Associated Types§

Source

type Receipt

The value a consumer hands back to the producer of an acked give OF THIS MESSAGE.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§