pub enum IrItem {
Type {
shape: TypeShape,
},
Fn {
receiver: Option<TyId>,
params: Vec<(String, TyId)>,
ret: TyId,
body: IrExpr,
effectful: bool,
},
Agent {
def: String,
key: (String, TyId),
state: Vec<StoreFieldIr>,
handlers: Vec<IrHandler>,
invariants: Vec<IrPredicate>,
transitions: Vec<IrPredicate>,
},
Service {
def: String,
protocol: ProtocolIr,
handlers: Vec<IrHandler>,
policy: Option<PolicyIr>,
},
Capability {
def: String,
ops: Vec<OpSig>,
},
Provider {
def: String,
cap: String,
body: ProviderBody,
},
}Expand description
P6.6’s real declaration IR (design/bynk-greenfield-compiler.md §6.6,
#1161) — a top-level declaration’s own shape, the payload
bynk_lower::lower_type_item_ir/bynk_lower::lower_fn_item_ir construct.
Identity is adapted per this module’s own “no arena” substitution
(DefId -> Arc<TypeDecl>/Arc<FnDecl>, the same substitution
Record/GlobalRef already made).
Type, Fn, Agent (P6.10, #1169), Service (P6.11, #1171),
Capability (P6.12, #1173) and Provider (P6.14, #1174) exist as
variants. Actor is still deferred (Decision D, #1161, matching the
issue’s own title: “Agent/Service/Actor/Capability/Provider deferred”).
This is a different posture from
Match’s own payload (IrPat/IrArm/Exhaustive/MatchForm), which
had to exist — even genuinely uninhabited — the moment
IrExprKind::Match’s own field list was written, because IrExprKind
is one enum whose whole Part 6.2 shape landed in a single slice (P6.1)
and never grows a new variant after. IrItem carries no such
constraint: nothing outside this module matches on it exhaustively yet
(no consumer at all, same posture as every prior P6.x slice), so a
later slice can add a wholly new variant rather than needing a
placeholder reserved here in advance. Each deferred variant has its own
real, distinct blocker, not a shared “later” (full grounding in #1161’s
own Decision D — Service’s own two blockers, closed by #1170/#1171,
are recorded on IrItem::Service’s own doc comment rather than kept
here as a stale bullet):
-
Actor— #1172’s own investigation settled this one as a non-build decision, not an unbuilt gap: the reference’s own sketch (Actor { def, scheme: AuthScheme, identity: Option<TyId>, claims: Option<IrExpr> },bynk-greenfield-compiler.md:1133) is the wrong shape for this codebase, on three independent findings. (1)claims: Option<IrExpr>is unbuildable, not merely unbuilt: an actor refinement’s own predicate (hasClaim/claimEquals,ActorRefinement::predicate) is validated only structurally (bynk-check/src/actors.rs’sparse_claim_predicate) — noCallee, noexpr_typesentry, no typing at all, because claims are deliberately untyped JSON (context_checks.rs’s ownrefinement_predicate_unsupportednote) and lowered straight to a JS string byclaim_predicate_to_js. AnIrExprhere would mean inventing a typing for a surface the checker deliberately never gave one. (2)scheme: AuthSchemenames a type the reference defines nowhere else (:1133/:1847only) — the same “referenced, not specified” gapCapability’s ownOpSigcarried beforeOpSigsettled it (P6.12, #1173), except here a real 5-variant candidate already ships (bynk-check::actors::Scheme), so this piece alone is specifiable. (3) The decisive finding: every real consumer of actor data — the fivebynk-checkseam resolvers the shipped emitter consumes (bearer_seam_for/oidc_seam_for/signature_seam_for/sum_members_for/caller_binder_for,bynk-check/src/actors.rs) and the reference’s own R8.11 (depsderivation)/R8.13 (boundary-wrapper verification) — is handler-keyed, not declaration-keyed: binder presence, sum-member ordering, and which scheme’s config applies are all facts about a handler’s ownbyclause, not theactordeclaration in isolation. This is exactly why the two actor-shaped IR additions that did have a real consumer (ActorBinder, andIrHandler’s ownactors: Vec<String>, review of #1180) both landed onIrHandler, not a newIrItemvariant — a{def, scheme, identity}record besideIrItem::Service’s handlers would have zero consumers and would not discharge R6.13 for actors at all, the “carve when a dependency arrives, not on appetite” anti-pattern R10.3 already argues against elsewhere in this track. Revisit only if a real phase-7 printer needs declaration-level actor data beyond whatIrHandler::binder/IrHandler::actorsalready carry — not before. -
Provider— #1174’s own investigation found this one buildable this slice, unlikeActor: the realProviderDecl(bynk-syntax/src/ast.rs:582-600) already carries the exactBynk/Externaldispatch the reference’s own// Bynk ops | External(module)comment names (never a real Rust enum in the document itself — the same “referenced, not specified” gapCapability’s ownOpSigcarried before #1173 settled it), viaexternal: boolplusops: Vec<ProviderOp>(empty exactly whenexternalistrue, per the field’s own doc comment,bynk-syntax/src/ast.rs:592-595). And unlikeCapabilityOp, aProviderOp’s own body is a real, fully type-checked handler body —check_provider_decls(bynk-check/src/context_checks.rs:626) pushes every op throughchecker::check_handler_body(:667) with the provider’s owngivenas its capability scope and noself/state/store binding at all (HandlerBodyCheck::new’s own “everything optional empty” default,bynk-check/src/checker.rs:1055) — sobynk_lower::lower_provider_op_irmirrorsbynk_lower::lower_fn_body_ir(ADR 0334 panic-on-miss, notbynk_lower::lower_op_sig_ir’s lenientTy::Unitfallback: this body’s types are checker-guaranteed to resolve, same as a fn’s) with no receiver/self and no rigid type variables (ProviderOpcarries none of its own,bynk-syntax/src/ast.rs:604-611).ProviderBody::Bynk’s ownops: Vec<ProviderOpIr>is real per-op signature-plus-body, oneProviderOpIrperbynk_lower::lower_provider_op_ircall, in declaration order.givenis carried,moduleis not — the two omissions are not symmetric (review of #1186). R8.1’s ownProvider{Bynk}row isexport classwith adepsconstructor (bynk-greenfield-compiler.md:1309), built today straight offProviderDecl::given(bynk-emit/src/project.rs:2608-2620) — unlikemodule,givenis not one-phase-up data, it lives on the veryProviderDeclthis function already holds, and it is not reconstructible from the lowered op bodies alone: an unusedgivencapability, a cross-contextgiven B.Capprefix (CapRef::context, v0.15), and declaration order would all silently vanish if this variant carried onlyops. SoProviderBody::Bynkalso carriesgiven: Vec<CapRefIr>—CapRefIradaptsCapRefunder this module’s usual “no arena, bare name” substitution (context’s ownQualifiedNameflattened via.joined()), leaving resolving a prefix againstconsumes/aliases to whichever future project-level pass also resolvesmodule—bynk_lower::lower_provider_item_irdoes no more thanbynk_lower::lower_capability_item_iralready declines to do for a capability op’s own type refs.ProviderBody::Externaldeliberately carries nomodulefield, despite the reference’s own parenthetical — that name lives one phase up from this per-contextCheckedProgram, on the adapter’s ownbinding "<module>"clause (BindingDecl::module,bynk-syntax/src/ast.rs:186), resolved only by the whole-project pass intoadapter_bindings: HashMap<String, AdapterBinding>(bynk-check/src/project_model.rs:729) — data no otherlower_X_item_irfunction in this module reaches either. Nothing needs it yet: R8.1’s own emission table already givesProvider{External}“nothing — the binding module supplies it” (bynk-greenfield-compiler.md:1310), i.e. even phase 7’s own per-item printer does not consume a module name — only the still-AST-drivenproject.rs’s existing import wiring does (bynk-emit/src/project.rs:2675-2678), untouched by this slice. Revisit only once a real project-level IR/linking phase gives this module something to thread the module name through.
Variants§
Type
A type declaration. shape covers all three real TypeShape
forms. P6.39: def: Arc<TypeDecl> dropped — its one production
consumer (emitter.rs’s type_shape_for call site) already ignored
it via .., and no other reader existed.
Fn
A fn declaration — free function or method alike (FnName::Free/
FnName::Method); which IrItem::Fns a future printer re-attaches
under which IrItem::Type’s own namespace (R8.1) is phase 7’s own
concern, not decided here. P6.39: def: Arc<FnDecl> dropped —
lower_fn_item_ir (the one constructor) has no production call site
at all today; every other field remains, so the constructor and this
variant both survive, just without the raw declaration.
Fields
receiver: Option<TyId>The method receiver’s own type, generic in the owning type’s own
rigid variables (e.g. Box[A]’s self is Ty::Named { name: "Box", args: [Ty::Var("A")], .. }) — None for a free function.
Not in params: self is never in f.params either
(FnDecl::has_self gates it, mirrored by
bynk_lower::lower_fn_body_ir’s own binding), but body still
references it as Local { name: "self" } when has_self is
true — a consumer that walks body needs this field to know
what that bare name resolves to, rather than re-deriving the
generic-receiver type itself from def.
params: Vec<(String, TyId)>Adapts the reference’s own bare Vec<LocalId> to Vec<(String, TyId)> (Decision E, #1161) — no arena exists to look a param’s
type back up from its name alone once this IrItem outlives the
LowerIrCtx that resolved it, unlike every other Decision-B
“name only” substitution in this module, where the type is
either implied by context or carried alongside on the same node
(e.g. IrExpr::ty).
body: IrExprbynk_lower::lower_fn_body_ir’s own return value, unchanged
(#1141) — this constructor adds no further transformation.
effectful: boolDerived once from ret’s structural shape (Ty::Fn’s own doc
comment, bynk-check/src/checker.rs: effectful iff ret is
Effect[_]), never threaded from anywhere else — the same
single-source-of-truth discipline this module already follows
for BindingMode/Exhaustive.
Agent
P6.10’s real IrItem::Agent (Part 6.6, R6.13, #1169) —
bynk_lower::lower_agent_item_ir’s own return value, assembling every
P6.7–P6.9 ingredient (StoreFieldIr, CommitShape/IrPredicate,
IrHandler) that had no IrItem variant to land in until now.
Matches the reference’s own sketch
(bynk-greenfield-compiler.md:1129-1131) field-for-field, under this
module’s already-established substitutions.
Fields
def: StringThe agent’s own declared name — this module’s usual “no arena”
substitution for the reference’s own DefId, but not the same
substitution IrItem::Type/IrItem::Fn made
(Arc<TypeDecl>/Arc<FnDecl>): unlike types/fns,
TypedCommons carries no Arc-wrapped agents table to source a
cheap pointer from (UnitTable::agents/CommonsItem::Agent are
both a plain, owned AgentDecl), and Callee::Agent { agent: String, handler: String } already establishes bare-name
identity as sufficient for this checked output — a full
AgentDecl clone (its own handler bodies included) would be
needless weight this module’s other String-identity fields
(GlobalRef::tag, Callee::Store::field, …) don’t carry either.
key: (String, TyId)key id: Type adapted from the reference’s own bare (LocalId, TyId) (Decision B extended): the bound name plus its resolved
type, the same Vec<(String, TyId)>-per-entry substitution
IrItem::Fn::params already made for a Vec<LocalId>.
state: Vec<StoreFieldIr>Every store field, bynk_lower::lower_store_field_ir’s own
return value, in declaration order.
handlers: Vec<IrHandler>Every on call handler, bynk_lower::lower_handler_ir’s own
return value, in declaration order.
invariants: Vec<IrPredicate>Every invariant, bynk_lower::lower_invariant_ir’s own return
value, in declaration order — the same already-lowered list each
handlers entry’s own commit: CommitShape::Transactional
(when it is one) carries a copy of, not a fresh lowering.
transitions: Vec<IrPredicate>Every transition, bynk_lower::lower_transition_ir’s own return
value, in declaration order — same relationship to handlers as
invariants.
Service
P6.11’s real IrItem::Service (Part 6.6, R6.13, #1171) —
bynk_lower::lower_service_item_ir’s own return value, the sibling
assembly to IrItem::Agent. Matches the reference’s own sketch
(bynk-greenfield-compiler.md:1132) field-for-field. Closes the two
blockers this variant carried while deferred: a real service
IrHandler needed the binder-persistence bynk-check change
#1170 made, and the CORS/security-headers/request-body-size policy
surface the reference sketch never shows at all now has a real,
specified shape (ProtocolIr/PolicyIr).
Fields
def: StringThe service’s own declared name — same reasoning as
IrItem::Agent’s own def: UnitTable::services is a plain
owned HashMap<String, ServiceDecl>, no Arc to borrow
cheaply, and bare-name identity is already sufficient for this
checked output.
protocol: ProtocolIrbynk_lower::lower_protocol_ir’s own return value.
handlers: Vec<IrHandler>Every handler, bynk_lower::lower_service_handler_ir’s own return
value, in declaration order.
policy: Option<PolicyIr>bynk_lower::lower_policy_ir’s own return value — None whenever
protocol is not ProtocolIr::Http, not just when the source
declares none of cors/security/limits. See PolicyIr’s
own doc comment for why this is Option, not the reference’s
own unconditional PolicyIr field.
Capability
P6.12’s real IrItem::Capability (Part 6.6, R6.13, #1173) —
bynk_lower::lower_capability_item_ir’s own return value. Matches the
reference’s own sketch (bynk-greenfield-compiler.md:1134)
field-for-field, once OpSig fills in the type the sketch names
but never defines.
Fields
def: StringThe capability’s own declared name — same reasoning as
IrItem::Agent/IrItem::Service’s own def:
UnitTable::capabilities is a plain owned HashMap<String, CapabilityDecl>, no Arc to borrow cheaply, and bare-name
identity is already sufficient — Callee::Capability { cap: String, op: String } (bynk-check/src/checker.rs) already
resolves a same-context capability call by name alone.
Provider
P6.14’s real IrItem::Provider (Part 6.6, R6.13, #1174) —
bynk_lower::lower_provider_item_ir’s own return value. Matches the
reference’s own sketch (bynk-greenfield-compiler.md:1135)
field-for-field, once ProviderBody fills in the type the
sketch’s own comment names but never defines as a real Rust enum.
Fields
def: StringThe provider’s own declared name (ProviderDecl::provider_name,
“used in tests/config to select impls”,
bynk-syntax/src/ast.rs:586) — distinct from cap below even
though UnitTable::providers happens to key by capability name
today (“one provider per capability in v0.5”,
bynk-check/src/symbols.rs): the reference’s own sketch keeps
def/cap as two separate DefIds, and a provider’s own
identity is never actually the capability it implements. Same
“no arena, bare name is enough” substitution as
IrItem::Agent/Service/Capability’s own def.
cap: StringThe capability this provider implements
(ProviderDecl::capability) — same bare-name substitution as
def; resolves against Callee::Capability’s own cap: String
the identical way IrItem::Capability::def does.
body: ProviderBodybynk_lower::lower_provider_item_ir’s own Bynk/External
dispatch, read straight off ProviderDecl::external.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for IrItem
impl RefUnwindSafe for IrItem
impl Send for IrItem
impl Sync for IrItem
impl Unpin for IrItem
impl UnsafeUnpin for IrItem
impl UnwindSafe for IrItem
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,
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);