pub enum WitTarget<'a> {
Http {
endpoint: &'a str,
},
PubSub {
subject: &'a str,
},
Store {
slot: &'a str,
},
Capability,
}Expand description
Typed view of a WitContract’s payload target. Each variant
carries the field its WIT shape requires; constructing a Http
view without an endpoint is impossible by the type system.
Renderers (caixa-mesh L7 rules, feira app graph) match on this
instead of probing Option<String> fields one by one — the
“which payload field is set?” question is answered once, at
validation time.
Variants§
Http
HTTP-shaped WIT world. Carries the configured request path.
PubSub
Pub-sub-shaped WIT world. Carries the event-stream subject.
The IsVariant derive would auto-name the predicate is_pub_sub
(discriminant_to_snake("PubSub") == "pub_sub"); the explicit
#[is_variant(name = "pubsub")] override keeps the emitted
method name byte-identical to the sibling
WitContract::is_pubsub predicate (the paired shape-side
arm-discriminator that routes through
wit_shape_is_pubsub on the wit-world-ref scalar rather than
through matches! on the variant), so the two arm-discriminator
axes — target-side variant-arm and shape-side ref-prefix — reach
every downstream consumer through the same is_pubsub() name.
Store
Key-value-shaped WIT world. Carries the slot template.
Capability
A typed capability edge with no payload selector — the WIT world stands on its own (rare; reserved for plain capability imports or M4-and-later WIT worlds we haven’t shaped yet).
Implementations§
Source§impl<'a> WitTarget<'a>
impl<'a> WitTarget<'a>
Sourcepub const HTTP_FIELD_NAME: &'static str = "endpoint"
pub const HTTP_FIELD_NAME: &'static str = "endpoint"
Canonical author-facing :contratos payload field name for the
HTTP-shaped arm — the expected: &'static str scalar the
AplicacaoError::ContratoMissingTarget /
AplicacaoError::ContratoWrongTarget diagnostic threads
through, the :endpoint "…" keyword the WitTarget::label
duplicate-edge diagnostic emits, and the endpoint=… prefix
the feira app graph verb prints. Peer of
WitTarget::PUBSUB_FIELD_NAME / WitTarget::STORE_FIELD_NAME
on the payload-field-name axis; declared as a peer const next
to the WitTarget::Http variant so a future rename on the
author-surface (defcaixa … :contratos ((:de … :para … :wit … :endpoint …))) field lands in exactly one place, not scattered
across the WitContract::target gate’s six expected:
literals, the label template, and every downstream consumer
that prints a per-arm prefix. Same trajectory as the peer
WitTarget::label lift (174e96a): a single source of truth
for the arm’s shape, next to the variant declaration.
Sourcepub const PUBSUB_FIELD_NAME: &'static str = "subject"
pub const PUBSUB_FIELD_NAME: &'static str = "subject"
Canonical author-facing :contratos payload field name for the
pub-sub-shaped arm. Peer of WitTarget::HTTP_FIELD_NAME /
WitTarget::STORE_FIELD_NAME on the payload-field-name axis;
see WitTarget::HTTP_FIELD_NAME for the full lift rationale.
Sourcepub const STORE_FIELD_NAME: &'static str = "slot"
pub const STORE_FIELD_NAME: &'static str = "slot"
Canonical author-facing :contratos payload field name for the
key/value-store-shaped arm. Peer of
WitTarget::HTTP_FIELD_NAME / WitTarget::PUBSUB_FIELD_NAME
on the payload-field-name axis; see
WitTarget::HTTP_FIELD_NAME for the full lift rationale.
Sourcepub const CAPABILITY_LABEL: &'static str = "(capability — no payload)"
pub const CAPABILITY_LABEL: &'static str = "(capability — no payload)"
Canonical stable human-readable label the payload-less
WitTarget::Capability arm renders as under Self::label —
the byte-string every consumer that formats a payload-less
typed capability edge as text lands on (the
AplicacaoSpec::validate duplicate-:contratos diagnostic
naming which identical edge was declared twice, the future
feira app graph verb’s per-arm prefix, the future M4 per-edge
policy resolver’s audit view, the operator’s mesh-graph audit).
Peer of the payload-arm Self::HTTP_FIELD_NAME /
Self::PUBSUB_FIELD_NAME / Self::STORE_FIELD_NAME
author-facing label-scalar consts — the same
“one canonical declaration per arm, next to the variant, so a
future rename lands in one place” discipline extended to the
payload-less arm. Until this lift landed the byte-string sat
twice — once inline in Self::label’s WitTarget::Capability
match arm, once in the pin test asserting the label’s
WitTarget::Capability output — with no compile-time link
between the two: a rebrand on either side (an operator-facing
vocabulary shift, a per-consumer disambiguation like
"(capability — no payload; typed edge only)") would silently
desynchronize until a downstream consumer surfaced the drift at
runtime.
Sourcepub const CAPABILITY_EXPECTED: &'static str = "none"
pub const CAPABILITY_EXPECTED: &'static str = "none"
Canonical expected: scalar the
AplicacaoError::ContratoWrongTarget diagnostic threads
through for the payload-less WitTarget::Capability arm — the
byte-string authors read as “this WIT world’s shape is not one
of {HTTP, PubSub, Store}, so it must not carry
:endpoint / :subject / :slot”. Peer of the payload-arm
Self::HTTP_FIELD_NAME / Self::PUBSUB_FIELD_NAME /
Self::STORE_FIELD_NAME consts on the
ContratoWrongTarget::expected axis — the fourth arm of the
same “which payload field name goes in the diagnostic” dispatch
the three payload-arm consts cover, extended to the payload-less
arm. Until this lift landed the byte-string sat twice — once
inline in the [Self::target] Capability-arm rejection at the
production dispatch, once in the pin test asserting the
diagnostic’s expected: scalar carries "none" verbatim — with
no compile-time link between the two: a rebrand on either side
(an author-facing vocabulary shift to "capability" /
"(none)" / "no-payload" as the WIT registry’s shape
vocabulary sharpens, a per-consumer disambiguation as M4 splits
WitTarget::Capability into per-shape peers) would silently
desynchronize until a downstream consumer surfaced the drift at
runtime. Same “one canonical declaration per arm, next to the
variant, so a future rename lands in one place” discipline the
peer Self::CAPABILITY_LABEL lift (7ed03a3-era) already
established for the payload-less arm’s human-readable label
axis; this lift extends it onto the peer diagnostic-scalar axis
so both halves of the “how does the Capability arm surface at
its two consumer axes (human-readable label, wrong-target
diagnostic)” pipeline route through peer consts declared next
to the variant.
Pairwise-distinctness against the three payload-arm scalars
(Self::HTTP_FIELD_NAME / Self::PUBSUB_FIELD_NAME /
Self::STORE_FIELD_NAME) is pinned by the sibling
wit_target_expected_scalars_are_pairwise_distinct_across_all_four_arms
test — the 4-way closure of the 3-way
wit_target_field_names_are_pairwise_distinct sibling pin onto
the ContratoWrongTarget::expected axis, matching the peer
m3_placement_estrategia_consts_are_pairwise_distinct closed-set
scalar-value distinctness discipline the sibling M3 typed-enum
discriminator axis already carries.
Sourcepub const fn payload_pair(&self) -> Option<(&'static str, &'a str)>
pub const fn payload_pair(&self) -> Option<(&'static str, &'a str)>
The (author-facing field name, payload) pair this typed target
arm carries — Some((HTTP_FIELD_NAME, endpoint)) for
Self::Http, Some((PUBSUB_FIELD_NAME, subject)) for
Self::PubSub, Some((STORE_FIELD_NAME, slot)) for
Self::Store, None for the payload-less
Self::Capability arm.
Lifted as the single 4-arm dispatch that both Self::label
(formats ":{field} {payload:?}" on Some, falls to
Self::CAPABILITY_LABEL on None) and Self::field_name
(returns the first component) route through, so a future
WitTarget variant addition — the M4-and-later per-edge WIT
registry may split Self::Http into Rest / Grpc peers,
or extend Self::Store with a Queue-shaped peer — becomes
exactly one new match-arm here (a compile-time exhaustiveness
error otherwise), not a coordinated three-way rewrite of the
prior Self::label template + Self::field_name dispatch
- every downstream consumer that reaches for the pair.
Until this lift landed the three payload arms sat in
Self::label as three near-identical format!(":{} {…:?}", …)
invocations (one per variant, each hand-quoting the paired
Self::HTTP_FIELD_NAME / Self::PUBSUB_FIELD_NAME /
Self::STORE_FIELD_NAME const) — the canonical
“same shape, written N times” duplication THEORY.md §I.3.5
(“Generation first, composition second, hand-authoring last;
the duplication budget is zero”) promotes to a build-time
concern, with each per-arm site paired to its own const with no
compile-time link between the format template and the arm’s
payload extraction.
Sourcepub const fn field_name(&self) -> Option<&'static str>
pub const fn field_name(&self) -> Option<&'static str>
The canonical author-facing :contratos payload field name
this typed target arm carries (Http → Some("endpoint"),
PubSub → Some("subject"), Store → Some("slot")), or
None for the payload-less Capability arm.
Routes through Self::payload_pair — the single 4-arm
dispatch Self::label also reads — so a future variant
addition is one match-arm edit at Self::payload_pair, not a
per-consumer rewrite. Same “exhaustive-match at one canonical
dispatch, thin projections at each consumer” trajectory the
peer PlacementStrategy::as_str / std::fmt::Display
pair (0a2f653) landed on the sibling M3 typed-enum axis.
Sourcepub fn label(&self) -> String
pub fn label(&self) -> String
Render this typed target as a stable human-readable label
(:endpoint "/charge", :subject "events.x",
:slot "checkout/$order", or (capability — no payload) when
the WIT world is a pure capability edge).
Used by the AplicacaoSpec::validate duplicate-:contratos
gate so the diagnostic names which identical edge was
declared twice (not just which (de, para, wit) triple).
Routes through the single 4-arm Self::payload_pair dispatch
on the payload-carrying arms (Some((field, payload)) → format!(":{field} {payload:?}")) and through the lifted
Self::CAPABILITY_LABEL const on the payload-less
Self::Capability arm — so a future variant addition (the
M4-and-later per-edge WIT registry may split Self::Http
into Rest / Grpc, or extend Self::Store with a
Queue-shaped peer) becomes a single new match-arm on
Self::payload_pair rather than a rewrite of this template
(and every downstream consumer that reaches for the label
shape: the per-edge policy resolver in M4, the feira app graph view, the operator’s mesh-graph audit). Until this
lift landed the three payload arms carried three near-identical
per-arm format!(":{} {…:?}", …) invocations, and the
Self::Capability arm carried the payload-less byte-string
twice (once inline here, once in the pin test) — closing the
duplication trajectory the peer Self::HTTP_FIELD_NAME /
Self::PUBSUB_FIELD_NAME / Self::STORE_FIELD_NAME (174e96a
/ 4a1e490) peer-const lifts already established for the
payload-carrying arms.
Trait Implementations§
impl<'a> Copy for WitTarget<'a>
Source§impl Display for WitTarget<'_>
std::fmt::Display routed through WitTarget::label, so the
pretty-printed byte-string every consumer that formats a typed
payload target as user-facing text lands on (the
AplicacaoError::ContratoDuplicate diagnostic’s target: carry
the AplicacaoSpec::validate duplicate-:contratos gate seeds via
WitTarget::label at aplicacao.rs:5491, the future feira app graph per-:contratos-edge payload column that reaches the graph
verb through format!("{target}"), the future M4 per-edge policy
resolver’s per-edge audit-log line, the operator’s mesh-graph
per-edge inspection view) reaches for the same lifted
WitTarget::HTTP_FIELD_NAME / WitTarget::PUBSUB_FIELD_NAME /
WitTarget::STORE_FIELD_NAME / WitTarget::CAPABILITY_LABEL
const set the WitTarget::payload_pair 4-arm dispatch already
routes through — extending the three-path-convergence
(Debug for structural inspection, Display for user-facing text,
per-arm typed accessor for the canonical byte-string) discipline the
sibling M3 PlacementStrategy and M2 crate::supervisor::RestartStrategy
/ crate::supervisor::RestartPolicy OTP-shape typed enums carry
onto the fourth (and only remaining) typed-shape-discriminator axis
on the caixa surface.
impl Display for WitTarget<'_>
std::fmt::Display routed through WitTarget::label, so the
pretty-printed byte-string every consumer that formats a typed
payload target as user-facing text lands on (the
AplicacaoError::ContratoDuplicate diagnostic’s target: carry
the AplicacaoSpec::validate duplicate-:contratos gate seeds via
WitTarget::label at aplicacao.rs:5491, the future feira app graph per-:contratos-edge payload column that reaches the graph
verb through format!("{target}"), the future M4 per-edge policy
resolver’s per-edge audit-log line, the operator’s mesh-graph
per-edge inspection view) reaches for the same lifted
WitTarget::HTTP_FIELD_NAME / WitTarget::PUBSUB_FIELD_NAME /
WitTarget::STORE_FIELD_NAME / WitTarget::CAPABILITY_LABEL
const set the WitTarget::payload_pair 4-arm dispatch already
routes through — extending the three-path-convergence
(Debug for structural inspection, Display for user-facing text,
per-arm typed accessor for the canonical byte-string) discipline the
sibling M3 PlacementStrategy and M2 crate::supervisor::RestartStrategy
/ crate::supervisor::RestartPolicy OTP-shape typed enums carry
onto the fourth (and only remaining) typed-shape-discriminator axis
on the caixa surface.
Pre-lift the two paths were structurally independent — every consumer
reaching for a payload byte-string past the WitTarget::label
helper had to pick between three paths (WitTarget::label,
format!("{v:?}") on the Debug derive, hand-rolled per-arm
formatting through the WitTarget::HTTP_FIELD_NAME /
WitTarget::PUBSUB_FIELD_NAME / WitTarget::STORE_FIELD_NAME /
WitTarget::CAPABILITY_LABEL const set), and a future consumer
that reached for format!("{target}") — the canonical shape every
user-facing pretty-print site on the sibling typed-enum axes already
uses — would silently land on the Debug derive’s structural output
(Http { endpoint: "/charge" } — Rust struct-literal syntax) rather
than the label() helper’s stable byte-string (:endpoint "/charge" — the author-facing :contratos keyword form) the
substrate-side duplicate-:contratos gate at aplicacao.rs:5491
already threads through. The two spellings would diverge silently in
every downstream diagnostic / graph / audit line reached through
format! rather than through the label() helper. Routing
std::fmt::Display through WitTarget::label closes the third
path: every format!("{v}") call reaches the same
WitTarget::payload_pair-shaped byte-string the label() helper
and the duplicate-:contratos gate already route through, so a
future variant addition (the M4-and-later per-edge WIT registry may
split WitTarget::Http into Rest / Grpc peers, or extend
WitTarget::Store with a Queue-shaped peer) reaches every
consumer at exactly one place — the WitTarget::payload_pair
match — rather than fanning out through hand-rolled per-arm
std::fmt::Display arms.
The dispatcher-catalog identity remains unaffected — WitTarget
is the typed view returned by WitContract::target, not a
closed-set discriminator enum with a gen-platform Discriminant
registration, so the Debug derive’s structural output (which every
{v:?} consumer still reaches) stays distinct from the Display
helper’s stable pretty-printed byte-string. Debug reveals variant
shape for structural inspection; Display (via label) reveals the
stable author-facing payload projection.
Pin tests
[tests::wit_target_display_routes_through_label_helper] and
[tests::wit_target_display_matches_duplicate_contratos_diagnostic_carrier]
assert the two paths agree byte-for-byte on every variant, so a
future variant addition or label() reimplementation that hand-rolls
the arms instead of delegating to WitTarget::payload_pair is a
build error visible at caixa-core test time, not a silent
per-consumer dispatch miss at diagnostic / audit / graph time.
impl<'a> Eq for WitTarget<'a>
impl<'a> StructuralPartialEq for WitTarget<'a>
Auto Trait Implementations§
impl<'a> Freeze for WitTarget<'a>
impl<'a> RefUnwindSafe for WitTarget<'a>
impl<'a> Send for WitTarget<'a>
impl<'a> Sync for WitTarget<'a>
impl<'a> Unpin for WitTarget<'a>
impl<'a> UnsafeUnpin for WitTarget<'a>
impl<'a> UnwindSafe for WitTarget<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.