Skip to main content

generated_support

Macro generated_support 

Source
macro_rules! generated_support {
    (
        expected: [
            185, 251, 251, 45, 168, 146, 85, 42, 248, 177, 196, 48, 117, 229, 207, 5,
            84, 120, 104, 25, 150, 41, 202, 2, 243, 73, 31, 148, 241, 22, 122, 34,
        ],
        harness: $harness:ident $(:: $harness_segment:ident)*,
        trials: { $($trials:tt)* },
        deferred: { $($deferred:tt)* },
    ) => { ... };
    (
        expected: [
            185, 251, 251, 45, 168, 146, 85, 42, 248, 177, 196, 48, 117, 229, 207, 5,
            84, 120, 104, 25, 150, 41, 202, 2, 243, 73, 31, 148, 241, 22, 122, 34,
        ],
        harness: $harness:ident $(:: $harness_segment:ident)*,
        benches: { $($benches:tt)* },
        reporter: { $($reporter:tt)* },
    ) => { ... };
    (
        expected: [$($expected:literal),* $(,)?],
        harness: $harness:ident $(:: $harness_segment:ident)*,
        trials: { $($trials:tt)* },
        deferred: { $($deferred:tt)* },
    ) => { ... };
    (
        expected: [$($expected:literal),* $(,)?],
        harness: $harness:ident $(:: $harness_segment:ident)*,
        benches: { $($benches:tt)* },
        reporter: { $($reporter:tt)* },
    ) => { ... };
    (@trials) => { ... };
    (@trials $($trials:tt)+) => { ... };
    (@benches $($benches:tt)+) => { ... };
}
Expand description

Guards one generated support delivery: compares the producer’s expected schema identity against the published one, and releases either the trial/deferred pair or the benchmark/reporter pair only when the two agree.

§The grammar

generated_support! {
    expected: [<the thirty-two published bytes, in decimal>],
    harness: <path>,
    trials: { <the trial_table! payload, verbatim> },
    deferred: { <opaque token trees, verbatim> },
}

generated_support! {
    expected: [<the thirty-two published bytes, in decimal>],
    harness: <path>,
    benches: { <the bench_table! payload, verbatim> },
    reporter: { <opaque token trees, verbatim> },
}
  • expected: is the producer’s own copy of the published identity, as thirty-two unsuffixed decimal byte values. Exactly one roster opens the gate; every other roster reaches the refusing arm.
  • harness: is the path this crate is reached by at the invocation site. The grammar captures its root and remaining segments separately, because Rust permits a repeated identifier sequence to be extended while a captured path fragment cannot be.
  • trials: is the row road, whose grammar is trial_table!’s exhaustively and which this gate neither reads nor rewrites. The seat may be empty: a producer whose whole cargo was deferred writes trials: { }, the matched arm stamps no table, and nothing is missing.
  • deferred: is the opaque seat, forwarded verbatim on the matched road and withheld entirely on the refusing one.
  • benches: is the benchmark-table road, whose grammar is bench_table!’s and whose admitted table is nonempty.
  • reporter: is opaque benchmark-target cargo, released inside the same matched arm as the benchmark table.

Both seats of the selected form are always written, in that order. Neither is optional: a seat a producer could omit is a seat it could place somewhere the pin does not reach.

§Authority

The declared harness path is load-bearing rather than decorative: the expansion writes one item naming this crate’s schema-identity type through both the declared path and $crate, and the two must be one type. A declaration that names another crate, or a path the consuming crate does not have, refuses at the door.

Agreement here means the two published sides are coherent, and nothing more. Releasing cargo is transport and never endorsement: the gate says the pin matched, and says nothing about opaque tokens it never read.

The @-prefixed rules below are internal transcriptions, not invocation forms. The forms above are text rather than compiled examples, because compiled rows need bindings that live on the challenge side.